opt: safearea

Signed-off-by: bggRGjQaUbCoE <githubaccount56556@proton.me>
This commit is contained in:
bggRGjQaUbCoE
2025-04-22 13:59:08 +08:00
parent 42fa4a2fff
commit 3afdd9d3f3
12 changed files with 327 additions and 336 deletions

View File

@@ -147,17 +147,17 @@ class _BangumiPageState extends CommonPageState<BangumiPage, BangumiController>
], ],
), ),
Expanded( Expanded(
child: TabBarView( child: MediaQuery.removePadding(
physics: const NeverScrollableScrollPhysics(), context: context,
children: loadingState.response!.map((item) { removeLeft:
if (item.episodes!.isNullOrEmpty) { context.orientation == Orientation.landscape,
return const SizedBox.shrink(); child: TabBarView(
} physics: const NeverScrollableScrollPhysics(),
return MediaQuery.removePadding( children: loadingState.response!.map((item) {
context: context, if (item.episodes!.isNullOrEmpty) {
removeLeft: context.orientation == return const SizedBox.shrink();
Orientation.landscape, }
child: ListView.builder( return ListView.builder(
physics: physics:
const AlwaysScrollableScrollPhysics(), const AlwaysScrollableScrollPhysics(),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
@@ -177,9 +177,9 @@ class _BangumiPageState extends CommonPageState<BangumiPage, BangumiController>
), ),
); );
}, },
), );
); }).toList()),
}).toList()), ),
), ),
], ],
), ),

View File

@@ -134,56 +134,59 @@ class _DynamicsPageState extends State<DynamicsPage>
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return Scaffold( return Scaffold(
resizeToAvoidBottomInset: false, resizeToAvoidBottomInset: false,
appBar: AppBar( appBar: AppBar(
leading: upPanelPosition == UpPanelPosition.rightDrawer leading: upPanelPosition == UpPanelPosition.rightDrawer
? _createDynamicBtn(false) ? _createDynamicBtn(false)
: null, : null,
leadingWidth: 50, leadingWidth: 50,
toolbarHeight: 50, toolbarHeight: 50,
title: SizedBox( title: SizedBox(
height: 50, height: 50,
child: TabBar( child: TabBar(
controller: _dynamicsController.tabController, controller: _dynamicsController.tabController,
isScrollable: true, isScrollable: true,
dividerColor: Colors.transparent, dividerColor: Colors.transparent,
dividerHeight: 0, dividerHeight: 0,
tabAlignment: TabAlignment.center, tabAlignment: TabAlignment.center,
indicatorColor: Theme.of(context).colorScheme.primary, indicatorColor: Theme.of(context).colorScheme.primary,
labelColor: Theme.of(context).colorScheme.primary, labelColor: Theme.of(context).colorScheme.primary,
unselectedLabelColor: Theme.of(context).colorScheme.onSurface, unselectedLabelColor: Theme.of(context).colorScheme.onSurface,
labelStyle: labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ?? TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13), const TextStyle(fontSize: 13),
tabs: tabs: DynamicsType.values.map((e) => Tab(text: e.labels)).toList(),
DynamicsType.values.map((e) => Tab(text: e.labels)).toList(), onTap: (index) {
onTap: (index) { if (!_dynamicsController.tabController.indexIsChanging) {
if (!_dynamicsController.tabController.indexIsChanging) { _dynamicsController.animateToTop();
_dynamicsController.animateToTop(); }
} },
},
),
), ),
actions: upPanelPosition == UpPanelPosition.rightDrawer
? null
: [_createDynamicBtn()],
), ),
drawer: upPanelPosition == UpPanelPosition.leftDrawer actions: upPanelPosition == UpPanelPosition.rightDrawer
? SafeArea(child: upPanelPart()) ? null
: null, : [_createDynamicBtn()],
drawerEnableOpenDragGesture: true, ),
endDrawer: upPanelPosition == UpPanelPosition.rightDrawer drawer: upPanelPosition == UpPanelPosition.leftDrawer
? SafeArea(child: upPanelPart()) ? SafeArea(child: upPanelPart())
: null, : null,
endDrawerEnableOpenDragGesture: true, drawerEnableOpenDragGesture: true,
body: Row(children: [ endDrawer: upPanelPosition == UpPanelPosition.rightDrawer
? SafeArea(child: upPanelPart())
: null,
endDrawerEnableOpenDragGesture: true,
body: Row(
children: [
if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(), if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(),
Expanded( Expanded(
child: tabBarView( child: tabBarView(
controller: _dynamicsController.tabController, controller: _dynamicsController.tabController,
children: _dynamicsController.tabsPageList, children: _dynamicsController.tabsPageList,
)), ),
),
if (upPanelPosition == UpPanelPosition.rightFixed) upPanelPart(), if (upPanelPosition == UpPanelPosition.rightFixed) upPanelPart(),
])); ],
),
);
} }
} }

View File

@@ -134,15 +134,13 @@ class _FavPageState extends State<FavPage> with SingleTickerProviderStateMixin {
tabs: _FavType.values.map((item) => Tab(text: item.title)).toList(), tabs: _FavType.values.map((item) => Tab(text: item.title)).toList(),
), ),
), ),
body: tabBarView( body: SafeArea(
controller: _tabController, top: false,
children: _FavType.values bottom: false,
.map((item) => SafeArea( child: tabBarView(
top: false, controller: _tabController,
bottom: false, children: _FavType.values.map((item) => item.page).toList(),
child: item.page, ),
))
.toList(),
), ),
); );
} }

View File

@@ -179,13 +179,13 @@ class _HistoryPageState extends State<HistoryPage>
), ),
body: Obx( body: Obx(
() => _historyController.tabs.isNotEmpty () => _historyController.tabs.isNotEmpty
? Column( ? SafeArea(
crossAxisAlignment: CrossAxisAlignment.start, top: false,
children: [ bottom: false,
SafeArea( child: Column(
top: false, crossAxisAlignment: CrossAxisAlignment.start,
bottom: false, children: [
child: TabBar( TabBar(
controller: _historyController.tabController, controller: _historyController.tabController,
onTap: (index) { onTap: (index) {
if (_historyController if (_historyController
@@ -206,47 +206,48 @@ class _HistoryPageState extends State<HistoryPage>
), ),
], ],
), ),
), Expanded(
Expanded( child: Material(
child: Material( color: Colors.transparent,
color: Colors.transparent, child: TabBarView(
child: TabBarView( physics: enableMultiSelect
physics: enableMultiSelect ? const NeverScrollableScrollPhysics()
? const NeverScrollableScrollPhysics() : const CustomTabBarViewScrollPhysics(),
: const CustomTabBarViewScrollPhysics(), controller:
controller: _historyController.tabController, _historyController.tabController,
children: [ children: [
_buildPage, _buildPage,
..._historyController.tabs.map( ..._historyController.tabs.map(
(item) => HistoryPage(type: item.type), (item) => HistoryPage(type: item.type),
), ),
], ],
),
), ),
), ),
), ],
], ),
) )
: _buildPage, : SafeArea(
top: false,
bottom: false,
child: _buildPage,
),
), ),
), ),
), ),
); );
} }
Widget get _buildPage => SafeArea( Widget get _buildPage => refreshIndicator(
top: false, onRefresh: () async {
bottom: false, await _historyController.onRefresh();
child: refreshIndicator( },
onRefresh: () async { child: CustomScrollView(
await _historyController.onRefresh(); physics: const AlwaysScrollableScrollPhysics(),
}, controller: _historyController.scrollController,
child: CustomScrollView( slivers: [
physics: const AlwaysScrollableScrollPhysics(), Obx(() => _buildBody(_historyController.loadingState.value)),
controller: _historyController.scrollController, ],
slivers: [
Obx(() => _buildBody(_historyController.loadingState.value)),
],
),
), ),
); );

View File

@@ -86,12 +86,12 @@ class _LaterPageState extends State<LaterPage>
) )
: const SizedBox(), : const SizedBox(),
), ),
body: Column( body: SafeArea(
children: [ top: false,
SafeArea( bottom: false,
top: false, child: Column(
bottom: false, children: [
child: TabBar( TabBar(
isScrollable: true, isScrollable: true,
controller: _tabController, controller: _tabController,
tabAlignment: TabAlignment.start, tabAlignment: TabAlignment.start,
@@ -110,23 +110,18 @@ class _LaterPageState extends State<LaterPage>
} }
}, },
), ),
), Expanded(
Expanded( child: TabBarView(
child: TabBarView( physics: _baseCtr.enableMultiSelect.value
physics: _baseCtr.enableMultiSelect.value ? const NeverScrollableScrollPhysics()
? const NeverScrollableScrollPhysics() : const CustomTabBarViewScrollPhysics(),
: const CustomTabBarViewScrollPhysics(), controller: _tabController,
controller: _tabController, children:
children: LaterViewType.values LaterViewType.values.map((item) => item.page).toList(),
.map((item) => SafeArea( ),
top: false,
bottom: false,
child: item.page,
))
.toList(),
), ),
), ],
], ),
), ),
), ),
), ),

View File

@@ -471,46 +471,54 @@ class _LoginPageState extends State<LoginPage> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
leading: IconButton( leading: IconButton(
tooltip: '关闭', tooltip: '关闭',
icon: const Icon(Icons.close_outlined), icon: const Icon(Icons.close_outlined),
onPressed: Get.back), onPressed: Get.back,
title: Row(children: [ ),
const Text('登录'), title: Row(
if (orientation == Orientation.landscape) ...[ children: [
const Spacer(), const Text('登录'),
Flexible( if (orientation == Orientation.landscape) ...[
const Spacer(flex: 3),
Flexible(
flex: 5,
child: TabBar( child: TabBar(
dividerHeight: 0, dividerHeight: 0,
tabs: const [ tabs: const [
Tab( Tab(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.password), Text(' 密码')], children: [Icon(Icons.password), Text(' 密码')],
), ),
),
Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.sms_outlined), Text(' 短信')],
),
),
Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.qr_code), Text(' 扫码')],
),
),
Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.cookie_outlined),
Text(' Cookie')
],
),
),
],
controller: _loginPageCtr.tabController,
), ),
Tab( )
child: Row( ],
mainAxisSize: MainAxisSize.min, ],
children: [Icon(Icons.sms_outlined), Text(' 短信')], ),
),
),
Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.qr_code), Text(' 扫码')],
),
),
Tab(
child: Row(
mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.cookie_outlined), Text(' Cookie')],
),
),
],
controller: _loginPageCtr.tabController,
))
]
]),
bottom: orientation == Orientation.portrait bottom: orientation == Orientation.portrait
? TabBar( ? TabBar(
tabs: const [ tabs: const [
@@ -548,12 +556,13 @@ class _LoginPageState extends State<LoginPage> {
Widget tabViewOuter(child) { Widget tabViewOuter(child) {
return SingleChildScrollView( return SingleChildScrollView(
child: Align( child: Align(
alignment: Alignment.topCenter, alignment: Alignment.topCenter,
child: SizedBox( child: ConstrainedBox(
height: 500, constraints: BoxConstraints(maxWidth: 600),
width: 600, child: child,
child: child, ),
))); ),
);
} }
} }

View File

@@ -173,12 +173,16 @@ class _MemberPageNewState extends State<MemberPageNew> {
]; ];
}, },
body: _userController.tab2?.isNotEmpty == true body: _userController.tab2?.isNotEmpty == true
? Column( ? SafeArea(
children: [ top: false,
if ((_userController.tab2?.length ?? 0) > 1) bottom: false,
_buildTab, child: Column(
Expanded(child: _buildBody), children: [
], if ((_userController.tab2?.length ?? 0) > 1)
_buildTab,
Expanded(child: _buildBody),
],
),
) )
: Center(child: const Text('EMPTY')), : Center(child: const Text('EMPTY')),
); );
@@ -193,49 +197,41 @@ class _MemberPageNewState extends State<MemberPageNew> {
Widget get _buildTab => Material( Widget get _buildTab => Material(
color: Theme.of(context).colorScheme.surface, color: Theme.of(context).colorScheme.surface,
child: SafeArea( child: TabBar(
top: false, controller: _userController.tabController,
bottom: false, tabs: _userController.tabs,
child: TabBar( onTap: (value) {
controller: _userController.tabController, if (_userController.tabController?.indexIsChanging == false) {
tabs: _userController.tabs, _key.currentState?.outerController.animToTop();
onTap: (value) { }
if (_userController.tabController?.indexIsChanging == false) { },
_key.currentState?.outerController.animToTop();
}
},
),
), ),
); );
Widget get _buildBody => SafeArea( Widget get _buildBody => tabBarView(
top: false, controller: _userController.tabController,
bottom: false, children: _userController.tab2!.map((item) {
child: tabBarView( return switch (item.param!) {
controller: _userController.tabController, 'home' => MemberHome(heroTag: _heroTag),
children: _userController.tab2!.map((item) { 'dynamic' => MemberDynamicsPage(mid: _mid),
return switch (item.param!) { 'contribute' => Obx(
'home' => MemberHome(heroTag: _heroTag), () => MemberContribute(
'dynamic' => MemberDynamicsPage(mid: _mid),
'contribute' => Obx(
() => MemberContribute(
heroTag: _heroTag,
initialIndex: _userController.contributeInitialIndex.value,
mid: _mid,
),
),
'bangumi' => MemberBangumi(
heroTag: _heroTag, heroTag: _heroTag,
initialIndex: _userController.contributeInitialIndex.value,
mid: _mid, mid: _mid,
), ),
'favorite' => MemberFavorite( ),
heroTag: _heroTag, 'bangumi' => MemberBangumi(
mid: _mid, heroTag: _heroTag,
), mid: _mid,
_ => Center(child: Text(item.title ?? '')), ),
}; 'favorite' => MemberFavorite(
}).toList(), heroTag: _heroTag,
), mid: _mid,
),
_ => Center(child: Text(item.title ?? '')),
};
}).toList(),
); );
Widget _buildAppBar({bool isV = true}) { Widget _buildAppBar({bool isV = true}) {

View File

@@ -28,26 +28,22 @@ class _SearchArchiveState extends State<SearchArchive>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return SafeArea( return refreshIndicator(
top: false, onRefresh: () async {
bottom: false, await widget.ctr.refreshArchive();
child: refreshIndicator( },
onRefresh: () async { child: CustomScrollView(
await widget.ctr.refreshArchive(); physics: const AlwaysScrollableScrollPhysics(),
}, slivers: [
child: CustomScrollView( SliverPadding(
physics: const AlwaysScrollableScrollPhysics(), padding: EdgeInsets.only(
slivers: [ top: StyleString.safeSpace - 5,
SliverPadding( bottom: MediaQuery.paddingOf(context).bottom + 80,
padding: EdgeInsets.only( ),
top: StyleString.safeSpace - 5, sliver:
bottom: MediaQuery.paddingOf(context).bottom + 80, Obx(() => _buildBody(context, widget.ctr.archiveState.value)),
), )
sliver: ],
Obx(() => _buildBody(context, widget.ctr.archiveState.value)),
)
],
),
), ),
); );
} }

View File

@@ -30,25 +30,21 @@ class _SearchDynamicState extends State<SearchDynamic>
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return SafeArea( return refreshIndicator(
top: false, onRefresh: () async {
bottom: false, await widget.ctr.refreshDynamic();
child: refreshIndicator( },
onRefresh: () async { child: CustomScrollView(
await widget.ctr.refreshDynamic(); physics: const AlwaysScrollableScrollPhysics(),
}, slivers: [
child: CustomScrollView( SliverPadding(
physics: const AlwaysScrollableScrollPhysics(), padding: EdgeInsets.only(
slivers: [ bottom: MediaQuery.paddingOf(context).bottom + 80,
SliverPadding( ),
padding: EdgeInsets.only( sliver:
bottom: MediaQuery.paddingOf(context).bottom + 80, Obx(() => _buildBody(context, widget.ctr.dynamicState.value)),
), )
sliver: ],
Obx(() => _buildBody(context, widget.ctr.dynamicState.value)),
)
],
),
), ),
); );
} }

View File

@@ -53,12 +53,12 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
), ),
body: Obx( body: Obx(
() => _memberSearchCtr.hasData.value () => _memberSearchCtr.hasData.value
? Column( ? SafeArea(
children: [ top: false,
SafeArea( bottom: false,
top: false, child: Column(
bottom: false, children: [
child: TabBar( TabBar(
controller: _memberSearchCtr.tabController, controller: _memberSearchCtr.tabController,
tabs: [ tabs: [
Obx( Obx(
@@ -75,17 +75,17 @@ class _MemberSearchPageState extends State<MemberSearchPage> {
), ),
], ],
), ),
), Expanded(
Expanded( child: tabBarView(
child: tabBarView( controller: _memberSearchCtr.tabController,
controller: _memberSearchCtr.tabController, children: [
children: [ SearchArchive(ctr: _memberSearchCtr),
SearchArchive(ctr: _memberSearchCtr), SearchDynamic(ctr: _memberSearchCtr),
SearchDynamic(ctr: _memberSearchCtr), ],
], ),
), ),
), ],
], ),
) )
: FractionallySizedBox( : FractionallySizedBox(
heightFactor: 0.5, heightFactor: 0.5,

View File

@@ -45,17 +45,14 @@ abstract class CommonSearchPanelState<
onRefresh: () async { onRefresh: () async {
await controller.onRefresh(); await controller.onRefresh();
}, },
child: SafeArea( child: CustomScrollView(
bottom: false, controller: controller.scrollController,
child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(),
controller: controller.scrollController, slivers: [
physics: const AlwaysScrollableScrollPhysics(), if (widget.hasHeader)
slivers: [ Obx(() => buildHeader(controller.loadingState.value)),
if (widget.hasHeader) Obx(() => _buildBody(controller.loadingState.value)),
Obx(() => buildHeader(controller.loadingState.value)), ],
Obx(() => _buildBody(controller.loadingState.value)),
],
),
), ),
); );
} }

View File

@@ -92,12 +92,12 @@ class _SearchResultPageState extends State<SearchResultPage>
), ),
), ),
), ),
body: Column( body: SafeArea(
children: [ top: false,
SafeArea( bottom: false,
top: false, child: Column(
bottom: false, children: [
child: SizedBox( SizedBox(
width: double.infinity, width: double.infinity,
child: TabBar( child: TabBar(
overlayColor: WidgetStateProperty.all(Colors.transparent), overlayColor: WidgetStateProperty.all(Colors.transparent),
@@ -145,54 +145,54 @@ class _SearchResultPageState extends State<SearchResultPage>
}, },
), ),
), ),
), Expanded(
Expanded( child: Material(
child: Material( color: Colors.transparent,
color: Colors.transparent, child: tabBarView(
child: tabBarView( controller: _tabController,
controller: _tabController, children: SearchType.values
children: SearchType.values .map(
.map( (item) => switch (item) {
(item) => switch (item) { // SearchType.all => SearchAllPanel(
// SearchType.all => SearchAllPanel( // tag: _tag,
// tag: _tag, // searchType: item,
// searchType: item, // keyword: _searchResultController.keyword,
// keyword: _searchResultController.keyword, // ),
// ), SearchType.video => SearchVideoPanel(
SearchType.video => SearchVideoPanel( tag: _tag,
tag: _tag, searchType: item,
searchType: item, keyword: _searchResultController.keyword,
keyword: _searchResultController.keyword, ),
), SearchType.media_bangumi ||
SearchType.media_bangumi || SearchType.media_ft =>
SearchType.media_ft => SearchPgcPanel(
SearchPgcPanel( tag: _tag,
tag: _tag, searchType: item,
searchType: item, keyword: _searchResultController.keyword,
keyword: _searchResultController.keyword, ),
), SearchType.live_room => SearchLivePanel(
SearchType.live_room => SearchLivePanel( tag: _tag,
tag: _tag, searchType: item,
searchType: item, keyword: _searchResultController.keyword,
keyword: _searchResultController.keyword, ),
), SearchType.bili_user => SearchUserPanel(
SearchType.bili_user => SearchUserPanel( tag: _tag,
tag: _tag, searchType: item,
searchType: item, keyword: _searchResultController.keyword,
keyword: _searchResultController.keyword, ),
), SearchType.article => SearchArticlePanel(
SearchType.article => SearchArticlePanel( tag: _tag,
tag: _tag, searchType: item,
searchType: item, keyword: _searchResultController.keyword,
keyword: _searchResultController.keyword, ),
), },
}, )
) .toList(),
.toList(), ),
), ),
), ),
), ],
], ),
), ),
); );
} }