handle viewinsets

Signed-off-by: dom <githubaccount56556@proton.me>
This commit is contained in:
dom
2026-05-24 23:55:20 +08:00
parent 12f7c88786
commit 3b16abf204
19 changed files with 88 additions and 75 deletions

View File

@@ -15,7 +15,7 @@ abstract class CommonSearchController<R, T> extends CommonListController<R, T> {
} }
@override @override
Future<void> onRefresh() { Future<void> onRefresh([_]) {
if (editController.value.text.isEmpty) { if (editController.value.text.isEmpty) {
return Future.syncValue(null); return Future.syncValue(null);
} }

View File

@@ -46,6 +46,9 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
ViewSliverSafeArea( ViewSliverSafeArea(
sliver: Obx(() => _buildBody(controller.loadingState.value)), sliver: Obx(() => _buildBody(controller.loadingState.value)),
), ),
SliverPadding(
padding: .only(bottom: MediaQuery.viewInsetsOf(context).bottom),
),
], ],
), ),
); );
@@ -81,7 +84,7 @@ abstract class CommonSearchPageState<S extends StatefulWidget, R, T>
..focusNode.requestFocus(), ..focusNode.requestFocus(),
), ),
), ),
onSubmitted: (value) => controller.onRefresh(), onSubmitted: controller.onRefresh,
), ),
); );
if (multiSelect) { if (multiSelect) {

View File

@@ -177,7 +177,12 @@ class _CreateFavPageState extends State<CreateFavPage> {
final leadingStyle = const TextStyle(fontSize: 14); final leadingStyle = const TextStyle(fontSize: 14);
Widget _buildBody(ThemeData theme) => SingleChildScrollView( Widget _buildBody(ThemeData theme) => SingleChildScrollView(
padding: .only(bottom: MediaQuery.viewPaddingOf(context).bottom + 25), padding: .only(
bottom:
MediaQuery.viewPaddingOf(context).bottom +
MediaQuery.viewInsetsOf(context).bottom +
25,
),
child: Column( child: Column(
spacing: 12, spacing: 12,
children: [ children: [
@@ -234,13 +239,10 @@ class _CreateFavPageState extends State<CreateFavPage> {
}, },
); );
}, },
leading: Text( leading: Text('封面', style: leadingStyle),
'封面',
style: leadingStyle,
),
trailing: Row( trailing: Row(
spacing: 10, spacing: 10,
mainAxisSize: MainAxisSize.min, mainAxisSize: .min,
children: [ children: [
if (_cover?.isNotEmpty == true) if (_cover?.isNotEmpty == true)
Padding( Padding(
@@ -309,10 +311,10 @@ class _CreateFavPageState extends State<CreateFavPage> {
color: theme.colorScheme.outline, color: theme.colorScheme.outline,
), ),
border: const OutlineInputBorder( border: const OutlineInputBorder(
borderSide: BorderSide.none, borderSide: .none,
gapPadding: 0, gapPadding: 0,
), ),
contentPadding: EdgeInsets.zero, contentPadding: .zero,
), ),
), ),
), ),
@@ -323,7 +325,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
ListTile( ListTile(
tileColor: theme.colorScheme.onInverseSurface, tileColor: theme.colorScheme.onInverseSurface,
title: Row( title: Row(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: .start,
children: [ children: [
SizedBox( SizedBox(
width: 55, width: 55,
@@ -364,7 +366,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
), ),
Builder( Builder(
builder: (context) { builder: (context) {
void onTap() { void onTap([_]) {
_isPublic = !_isPublic; _isPublic = !_isPublic;
(context as Element).markNeedsBuild(); (context as Element).markNeedsBuild();
} }
@@ -381,7 +383,7 @@ class _CreateFavPageState extends State<CreateFavPage> {
scale: 0.8, scale: 0.8,
child: Switch( child: Switch(
value: _isPublic, value: _isPublic,
onChanged: (value) => onTap(), onChanged: onTap,
), ),
), ),
); );

View File

@@ -42,11 +42,14 @@ class _LiveSearchChildPageState extends State<LiveSearchChildPage>
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
slivers: [ slivers: [
SliverPadding( SliverPadding(
padding: EdgeInsets.only( padding: .only(
top: padding, top: padding,
left: padding, left: padding,
right: padding, right: padding,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100, bottom:
MediaQuery.viewPaddingOf(context).bottom +
MediaQuery.viewInsetsOf(context).bottom +
100,
), ),
sliver: Obx(() => _buildBody(_controller.loadingState.value)), sliver: Obx(() => _buildBody(_controller.loadingState.value)),
), ),

View File

@@ -45,7 +45,7 @@ class LiveSearchController extends GetxController
} }
} }
void submit() { void submit([_]) {
if (editingController.text.isNotEmpty) { if (editingController.text.isNotEmpty) {
if (IdUtils.digitOnlyRegExp.hasMatch(editingController.text)) { if (IdUtils.digitOnlyRegExp.hasMatch(editingController.text)) {
PageUtils.toLiveRoom(int.parse(editingController.text)); PageUtils.toLiveRoom(int.parse(editingController.text));

View File

@@ -49,7 +49,7 @@ class _LiveSearchPageState extends State<LiveSearchPage> {
onPressed: _controller.onClear, onPressed: _controller.onClear,
), ),
), ),
onSubmitted: (value) => _controller.submit(), onSubmitted: _controller.submit,
onChanged: (value) { onChanged: (value) {
if (value.isEmpty) { if (value.isEmpty) {
_controller.hasData.value = false; _controller.hasData.value = false;

View File

@@ -39,9 +39,12 @@ class _LoginPageState extends State<LoginPage> {
void didChangeDependencies() { void didChangeDependencies() {
super.didChangeDependencies(); super.didChangeDependencies();
_loginPageCtr.didChangeDependencies(context); _loginPageCtr.didChangeDependencies(context);
padding = final padding = MediaQuery.viewPaddingOf(context);
MediaQuery.viewPaddingOf(context).copyWith(top: 0) + this.padding = .only(
const EdgeInsets.only(bottom: 25); left: padding.left,
right: padding.right,
bottom: padding.bottom + MediaQuery.viewInsetsOf(context).bottom + 25,
);
} }
Widget loginByQRCode(ThemeData theme) { Widget loginByQRCode(ThemeData theme) {

View File

@@ -85,13 +85,11 @@ class _EditProfilePageState extends State<EditProfilePage> {
if (mounted) { if (mounted) {
setState(() { setState(() {
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
AccountMyInfoData data = AccountMyInfoData.fromJson( final data = AccountMyInfoData.fromJson(res.data['data']);
res.data['data'],
);
_loadingState = Success(data); _loadingState = Success(data);
accountService.face.value = data.face!; accountService.face.value = data.face!;
try { try {
UserInfoData userInfo = Pref.userInfoCache! final userInfo = Pref.userInfoCache!
..uname = data.name ..uname = data.name
..face = data.face; ..face = data.face;
GStorage.userInfo.put('userInfoCache', userInfo); GStorage.userInfo.put('userInfoCache', userInfo);
@@ -162,7 +160,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
SmartDialog.showToast('硬币不足'); SmartDialog.showToast('硬币不足');
} else { } else {
_editDialog( _editDialog(
type: ProfileType.uname, type: .uname,
title: '昵称', title: '昵称',
text: response.name!, text: response.name!,
); );
@@ -193,7 +191,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
).then((res) { ).then((res) {
if (res != null) { if (res != null) {
_update( _update(
type: ProfileType.birthday, type: .birthday,
datum: DateFormatUtils.longFormat.format(res), datum: DateFormatUtils.longFormat.format(res),
); );
} }
@@ -205,7 +203,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
title: '个性签名', title: '个性签名',
text: response.sign, text: response.sign,
onTap: () => _editDialog( onTap: () => _editDialog(
type: ProfileType.sign, type: .sign,
title: '个性签名', title: '个性签名',
text: response.sign ?? '', text: response.sign ?? '',
), ),
@@ -277,7 +275,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
trailing: current == sex ? const Icon(size: 22, Icons.check) : null, trailing: current == sex ? const Icon(size: 22, Icons.check) : null,
onTap: () { onTap: () {
Get.back(); Get.back();
_update(type: ProfileType.sex, datum: sex); _update(type: .sex, datum: sex);
}, },
); );
} }
@@ -288,7 +286,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
required String text, required String text,
}) { }) {
_textController.text = text; _textController.text = text;
final lines = type == ProfileType.uname ? 1 : 4; final lines = type == .uname ? 1 : 4;
showDialog( showDialog(
context: context, context: context,
builder: (BuildContext context) { builder: (BuildContext context) {
@@ -301,13 +299,9 @@ class _EditProfilePageState extends State<EditProfilePage> {
maxLines: lines, maxLines: lines,
autofocus: true, autofocus: true,
style: const TextStyle(fontSize: 14), style: const TextStyle(fontSize: 14),
textInputAction: type == ProfileType.sign textInputAction: type == .sign ? .newline : null,
? TextInputAction.newline
: null,
inputFormatters: [ inputFormatters: [
LengthLimitingTextInputFormatter( LengthLimitingTextInputFormatter(type == .uname ? 16 : 70),
type == ProfileType.uname ? 16 : 70,
),
], ],
decoration: InputDecoration( decoration: InputDecoration(
hintText: text, hintText: text,
@@ -359,13 +353,13 @@ class _EditProfilePageState extends State<EditProfilePage> {
'platform': 'android', 'platform': 'android',
's_locale': 'zh_CN', 's_locale': 'zh_CN',
'statistics': Constants.statistics, 'statistics': Constants.statistics,
if (type == ProfileType.uname) if (type == .uname)
'uname': _textController.text 'uname': _textController.text
else if (type == ProfileType.sign) else if (type == .sign)
'user_sign': _textController.text 'user_sign': _textController.text
else if (type == ProfileType.birthday) else if (type == .birthday)
'birthday': datum 'birthday': datum
else if (type == ProfileType.sex) else if (type == .sex)
'sex': datum.toString(), 'sex': datum.toString(),
}; };
AppSign.appSign(data); AppSign.appSign(data);
@@ -378,7 +372,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
).then((res) { ).then((res) {
if (res.data['code'] == 0) { if (res.data['code'] == 0) {
AccountMyInfoData data = _loadingState.data; AccountMyInfoData data = _loadingState.data;
if (type == ProfileType.uname) { if (type == .uname) {
data data
..name = _textController.text ..name = _textController.text
..coins = data.coins! - 6; ..coins = data.coins! - 6;
@@ -392,18 +386,18 @@ class _EditProfilePageState extends State<EditProfilePage> {
..value.uname = _textController.text ..value.uname = _textController.text
..refresh(); ..refresh();
} catch (_) {} } catch (_) {}
} else if (type == ProfileType.sign) { } else if (type == .sign) {
data.sign = _textController.text; data.sign = _textController.text;
} else if (type == ProfileType.birthday) { } else if (type == .birthday) {
data.birthday = datum; data.birthday = datum;
} else if (type == ProfileType.sex) { } else if (type == .sex) {
data.sex = datum; data.sex = datum;
} }
SmartDialog.showToast('修改成功'); SmartDialog.showToast('修改成功');
if (mounted) { if (mounted) {
setState(() {}); setState(() {});
} }
if (type == ProfileType.uname || type == ProfileType.sign) { if (type == .uname || type == .sign) {
Get.back(); Get.back();
} }
} else { } else {
@@ -436,21 +430,21 @@ class _EditProfilePageState extends State<EditProfilePage> {
title, title,
style: const TextStyle( style: const TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.normal, fontWeight: .normal,
), ),
), ),
title: Row( title: Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: .end,
children: [ children: [
if (text != null) if (text != null)
Flexible( Flexible(
child: Text( child: Text(
text, text,
maxLines: 1, maxLines: 1,
overflow: TextOverflow.ellipsis, overflow: .ellipsis,
style: TextStyle( style: TextStyle(
fontSize: 14, fontSize: 14,
fontWeight: FontWeight.normal, fontWeight: .normal,
color: theme.colorScheme.outline, color: theme.colorScheme.outline,
), ),
), ),
@@ -472,7 +466,7 @@ class _EditProfilePageState extends State<EditProfilePage> {
Future<void> _pickImg(ThemeData theme) async { Future<void> _pickImg(ThemeData theme) async {
try { try {
XFile? pickedFile = await _imagePicker.pickImage( XFile? pickedFile = await _imagePicker.pickImage(
source: ImageSource.gallery, source: .gallery,
imageQuality: 100, imageQuality: 100,
); );
if (pickedFile != null && mounted) { if (pickedFile != null && mounted) {
@@ -496,13 +490,13 @@ class _EditProfilePageState extends State<EditProfilePage> {
aspectRatioPresets: const [CropAspectRatioPresetCustom()], aspectRatioPresets: const [CropAspectRatioPresetCustom()],
lockAspectRatio: true, lockAspectRatio: true,
hideBottomControls: true, hideBottomControls: true,
cropStyle: CropStyle.circle, cropStyle: .circle,
initAspectRatio: const CropAspectRatioPresetCustom(), initAspectRatio: const CropAspectRatioPresetCustom(),
), ),
IOSUiSettings( IOSUiSettings(
title: '裁剪', title: '裁剪',
aspectRatioPresets: const [CropAspectRatioPresetCustom()], aspectRatioPresets: const [CropAspectRatioPresetCustom()],
cropStyle: CropStyle.circle, cropStyle: .circle,
aspectRatioLockEnabled: true, aspectRatioLockEnabled: true,
resetAspectRatioEnabled: false, resetAspectRatioEnabled: false,
aspectRatioPickerButtonHidden: true, aspectRatioPickerButtonHidden: true,

View File

@@ -43,7 +43,10 @@ class _MemberSearchChildPageState extends State<MemberSearchChildPage>
SliverPadding( SliverPadding(
padding: EdgeInsets.only( padding: EdgeInsets.only(
top: widget.searchType == MemberSearchType.archive ? 7 : 0, top: widget.searchType == MemberSearchType.archive ? 7 : 0,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100, bottom:
MediaQuery.viewPaddingOf(context).bottom +
MediaQuery.viewInsetsOf(context).bottom +
100,
), ),
sliver: switch (widget.searchType) { sliver: switch (widget.searchType) {
MemberSearchType.archive => Obx( MemberSearchType.archive => Obx(

View File

@@ -47,7 +47,7 @@ class MemberSearchController extends GetxController
} }
} }
void submit() { void submit([_]) {
if (editingController.text.isNotEmpty) { if (editingController.text.isNotEmpty) {
hasData.value = true; hasData.value = true;
arcCtr arcCtr

View File

@@ -49,7 +49,7 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
onPressed: _controller.onClear, onPressed: _controller.onClear,
), ),
), ),
onSubmitted: (value) => _controller.submit(), onSubmitted: _controller.submit,
onChanged: (value) { onChanged: (value) {
if (value.isEmpty) { if (value.isEmpty) {
_controller.hasData.value = false; _controller.hasData.value = false;

View File

@@ -138,7 +138,7 @@ class SSearchController extends GetxController
} }
// 搜索 // 搜索
Future<void> submit() async { Future<void> submit([_]) async {
if (controller.text.isEmpty) { if (controller.text.isEmpty) {
if (hintText.isNullOrEmpty) { if (hintText.isNullOrEmpty) {
return; return;

View File

@@ -57,10 +57,13 @@ class _SearchPageState extends State<SearchPage> {
trending, trending,
_buildHistory, _buildHistory,
] else ] else
SliverCrossAxisGroup( SliverCrossAxisGroup(slivers: [trending, _buildHistory]),
slivers: [trending, _buildHistory], SliverPadding(
padding: .only(
bottom:
padding.bottom + MediaQuery.viewInsetsOf(context).bottom,
), ),
SliverPadding(padding: .only(bottom: padding.bottom)), ),
], ],
), ),
), ),
@@ -109,7 +112,7 @@ class _SearchPageState extends State<SearchPage> {
hintText: _searchController.hintText ?? '搜索', hintText: _searchController.hintText ?? '搜索',
border: InputBorder.none, border: InputBorder.none,
), ),
onSubmitted: (value) => _searchController.submit(), onSubmitted: _searchController.submit,
), ),
); );

View File

@@ -105,6 +105,9 @@ class _SettingsSearchPageState
), ),
), ),
), ),
SliverPadding(
padding: .only(bottom: MediaQuery.viewInsetsOf(context).bottom),
),
], ],
), ),
); );

View File

@@ -38,9 +38,12 @@ class _ReplySearchChildPageState extends State<ReplySearchChildPage>
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
slivers: [ slivers: [
SliverPadding( SliverPadding(
padding: EdgeInsets.only( padding: .only(
top: 7, top: 7,
bottom: MediaQuery.viewPaddingOf(context).bottom + 100, bottom:
MediaQuery.viewPaddingOf(context).bottom +
MediaQuery.viewInsetsOf(context).bottom +
100,
), ),
sliver: Obx(() => _buildBody(_controller.loadingState.value)), sliver: Obx(() => _buildBody(_controller.loadingState.value)),
), ),

View File

@@ -42,7 +42,7 @@ class ReplySearchController extends GetxController
submit(); submit();
} }
void submit() { void submit([_]) {
videoCtr videoCtr
..scrollController.jumpToTop() ..scrollController.jumpToTop()
..onReload(); ..onReload();

View File

@@ -62,7 +62,7 @@ class _ReplySearchPageState extends State<ReplySearchPage> {
onPressed: _controller.onClear, onPressed: _controller.onClear,
), ),
), ),
onSubmitted: (value) => _controller.submit(), onSubmitted: _controller.submit,
), ),
), ),
body: ViewSafeArea( body: ViewSafeArea(

View File

@@ -30,7 +30,7 @@ class ImSettingsItem extends StatelessWidget {
final subtitleStyle = TextStyle(fontSize: 13, color: outline); final subtitleStyle = TextStyle(fontSize: 13, color: outline);
if (item.hasSwitch_1()) { if (item.hasSwitch_1()) {
Future<void> onChanged() async { Future<void> onChanged([_]) async {
item.switch_1.switchOn = !item.switch_1.switchOn; item.switch_1.switchOn = !item.switch_1.switchOn;
rebuild(); rebuild();
if (!await onSet()) { if (!await onSet()) {
@@ -54,7 +54,7 @@ class ImSettingsItem extends StatelessWidget {
scale: 0.8, scale: 0.8,
child: Switch( child: Switch(
value: item.switch_1.switchOn, value: item.switch_1.switchOn,
onChanged: (value) => onChanged(), onChanged: onChanged,
), ),
), ),
); );

View File

@@ -1756,11 +1756,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: BackwardSeekIndicator( child: BackwardSeekIndicator(
duration: duration:
plPlayerController.fastForBackwardDuration, plPlayerController.fastForBackwardDuration,
onSubmitted: (Duration value) { onSubmitted: (value) => plPlayerController
plPlayerController ..mountSeekBackwardButton.value = false
..mountSeekBackwardButton.value = false ..onBackward(value),
..onBackward(value);
},
), ),
), ),
), ),
@@ -1777,11 +1775,9 @@ class _PLVideoPlayerState extends State<PLVideoPlayer>
child: ForwardSeekIndicator( child: ForwardSeekIndicator(
duration: duration:
plPlayerController.fastForBackwardDuration, plPlayerController.fastForBackwardDuration,
onSubmitted: (Duration value) { onSubmitted: (value) => plPlayerController
plPlayerController ..mountSeekForwardButton.value = false
..mountSeekForwardButton.value = false ..onForward(value),
..onForward(value);
},
), ),
), ),
), ),