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

View File

@@ -155,8 +155,7 @@ class _DynamicsPageState extends State<DynamicsPage>
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();
@@ -176,14 +175,18 @@ class _DynamicsPageState extends State<DynamicsPage>
? SafeArea(child: upPanelPart()) ? SafeArea(child: upPanelPart())
: null, : null,
endDrawerEnableOpenDragGesture: true, endDrawerEnableOpenDragGesture: true,
body: Row(children: [ 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,
children: _FavType.values
.map((item) => SafeArea(
top: false, top: false,
bottom: false, bottom: false,
child: item.page, child: tabBarView(
)) controller: _tabController,
.toList(), children: _FavType.values.map((item) => 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,
children: [
SafeArea(
top: false, top: false,
bottom: false, bottom: false,
child: TabBar( child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
TabBar(
controller: _historyController.tabController, controller: _historyController.tabController,
onTap: (index) { onTap: (index) {
if (_historyController if (_historyController
@@ -206,7 +206,6 @@ class _HistoryPageState extends State<HistoryPage>
), ),
], ],
), ),
),
Expanded( Expanded(
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
@@ -214,7 +213,8 @@ class _HistoryPageState extends State<HistoryPage>
physics: enableMultiSelect physics: enableMultiSelect
? const NeverScrollableScrollPhysics() ? const NeverScrollableScrollPhysics()
: const CustomTabBarViewScrollPhysics(), : const CustomTabBarViewScrollPhysics(),
controller: _historyController.tabController, controller:
_historyController.tabController,
children: [ children: [
_buildPage, _buildPage,
..._historyController.tabs.map( ..._historyController.tabs.map(
@@ -225,18 +225,20 @@ class _HistoryPageState extends State<HistoryPage>
), ),
), ),
], ],
),
) )
: _buildPage, : SafeArea(
top: false,
bottom: false,
child: _buildPage,
),
), ),
), ),
), ),
); );
} }
Widget get _buildPage => SafeArea( Widget get _buildPage => refreshIndicator(
top: false,
bottom: false,
child: refreshIndicator(
onRefresh: () async { onRefresh: () async {
await _historyController.onRefresh(); await _historyController.onRefresh();
}, },
@@ -247,7 +249,6 @@ class _HistoryPageState extends State<HistoryPage>
Obx(() => _buildBody(_historyController.loadingState.value)), Obx(() => _buildBody(_historyController.loadingState.value)),
], ],
), ),
),
); );
Widget _buildBody(LoadingState<List<HisListItem>?> loadingState) { Widget _buildBody(LoadingState<List<HisListItem>?> loadingState) {

View File

@@ -86,12 +86,12 @@ class _LaterPageState extends State<LaterPage>
) )
: const SizedBox(), : const SizedBox(),
), ),
body: Column( body: SafeArea(
children: [
SafeArea(
top: false, top: false,
bottom: false, bottom: false,
child: TabBar( child: Column(
children: [
TabBar(
isScrollable: true, isScrollable: true,
controller: _tabController, controller: _tabController,
tabAlignment: TabAlignment.start, tabAlignment: TabAlignment.start,
@@ -110,26 +110,21 @@ 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: LaterViewType.values children:
.map((item) => SafeArea( LaterViewType.values.map((item) => item.page).toList(),
top: false,
bottom: false,
child: item.page,
))
.toList(),
), ),
), ),
], ],
), ),
), ),
), ),
),
); );
} }

View File

@@ -473,12 +473,15 @@ class _LoginPageState extends State<LoginPage> {
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: [ ),
title: Row(
children: [
const Text('登录'), const Text('登录'),
if (orientation == Orientation.landscape) ...[ if (orientation == Orientation.landscape) ...[
const Spacer(), const Spacer(flex: 3),
Flexible( Flexible(
flex: 5,
child: TabBar( child: TabBar(
dividerHeight: 0, dividerHeight: 0,
tabs: const [ tabs: const [
@@ -503,14 +506,19 @@ class _LoginPageState extends State<LoginPage> {
Tab( Tab(
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [Icon(Icons.cookie_outlined), Text(' Cookie')], children: [
Icon(Icons.cookie_outlined),
Text(' Cookie')
],
), ),
), ),
], ],
controller: _loginPageCtr.tabController, controller: _loginPageCtr.tabController,
)) ),
] )
]), ],
],
),
bottom: orientation == Orientation.portrait bottom: orientation == Orientation.portrait
? TabBar( ? TabBar(
tabs: const [ tabs: const [
@@ -550,10 +558,11 @@ class _LoginPageState extends State<LoginPage> {
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(
top: false,
bottom: false,
child: Column(
children: [ children: [
if ((_userController.tab2?.length ?? 0) > 1) if ((_userController.tab2?.length ?? 0) > 1)
_buildTab, _buildTab,
Expanded(child: _buildBody), Expanded(child: _buildBody),
], ],
),
) )
: Center(child: const Text('EMPTY')), : Center(child: const Text('EMPTY')),
); );
@@ -193,9 +197,6 @@ 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(
top: false,
bottom: false,
child: TabBar( child: TabBar(
controller: _userController.tabController, controller: _userController.tabController,
tabs: _userController.tabs, tabs: _userController.tabs,
@@ -205,13 +206,9 @@ class _MemberPageNewState extends State<MemberPageNew> {
} }
}, },
), ),
),
); );
Widget get _buildBody => SafeArea( Widget get _buildBody => tabBarView(
top: false,
bottom: false,
child: tabBarView(
controller: _userController.tabController, controller: _userController.tabController,
children: _userController.tab2!.map((item) { children: _userController.tab2!.map((item) {
return switch (item.param!) { return switch (item.param!) {
@@ -235,7 +232,6 @@ class _MemberPageNewState extends State<MemberPageNew> {
_ => Center(child: Text(item.title ?? '')), _ => Center(child: Text(item.title ?? '')),
}; };
}).toList(), }).toList(),
),
); );
Widget _buildAppBar({bool isV = true}) { Widget _buildAppBar({bool isV = true}) {

View File

@@ -28,10 +28,7 @@ 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,
bottom: false,
child: refreshIndicator(
onRefresh: () async { onRefresh: () async {
await widget.ctr.refreshArchive(); await widget.ctr.refreshArchive();
}, },
@@ -48,7 +45,6 @@ class _SearchArchiveState extends State<SearchArchive>
) )
], ],
), ),
),
); );
} }

View File

@@ -30,10 +30,7 @@ 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,
bottom: false,
child: refreshIndicator(
onRefresh: () async { onRefresh: () async {
await widget.ctr.refreshDynamic(); await widget.ctr.refreshDynamic();
}, },
@@ -49,7 +46,6 @@ class _SearchDynamicState extends State<SearchDynamic>
) )
], ],
), ),
),
); );
} }

View File

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

View File

@@ -45,8 +45,6 @@ abstract class CommonSearchPanelState<
onRefresh: () async { onRefresh: () async {
await controller.onRefresh(); await controller.onRefresh();
}, },
child: SafeArea(
bottom: false,
child: CustomScrollView( child: CustomScrollView(
controller: controller.scrollController, controller: controller.scrollController,
physics: const AlwaysScrollableScrollPhysics(), physics: const AlwaysScrollableScrollPhysics(),
@@ -56,7 +54,6 @@ abstract class CommonSearchPanelState<
Obx(() => _buildBody(controller.loadingState.value)), Obx(() => _buildBody(controller.loadingState.value)),
], ],
), ),
),
); );
} }

View File

@@ -92,12 +92,12 @@ class _SearchResultPageState extends State<SearchResultPage>
), ),
), ),
), ),
body: Column( body: SafeArea(
children: [
SafeArea(
top: false, top: false,
bottom: false, bottom: false,
child: SizedBox( child: Column(
children: [
SizedBox(
width: double.infinity, width: double.infinity,
child: TabBar( child: TabBar(
overlayColor: WidgetStateProperty.all(Colors.transparent), overlayColor: WidgetStateProperty.all(Colors.transparent),
@@ -145,7 +145,6 @@ class _SearchResultPageState extends State<SearchResultPage>
}, },
), ),
), ),
),
Expanded( Expanded(
child: Material( child: Material(
color: Colors.transparent, color: Colors.transparent,
@@ -194,6 +193,7 @@ class _SearchResultPageState extends State<SearchResultPage>
), ),
], ],
), ),
),
); );
} }
} }