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(
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
children: loadingState.response!.map((item) {
if (item.episodes!.isNullOrEmpty) {
return const SizedBox.shrink();
}
return MediaQuery.removePadding(
context: context,
removeLeft: context.orientation ==
Orientation.landscape,
child: ListView.builder(
child: MediaQuery.removePadding(
context: context,
removeLeft:
context.orientation == Orientation.landscape,
child: TabBarView(
physics: const NeverScrollableScrollPhysics(),
children: loadingState.response!.map((item) {
if (item.episodes!.isNullOrEmpty) {
return const SizedBox.shrink();
}
return ListView.builder(
physics:
const AlwaysScrollableScrollPhysics(),
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) {
super.build(context);
return Scaffold(
resizeToAvoidBottomInset: false,
appBar: AppBar(
leading: upPanelPosition == UpPanelPosition.rightDrawer
? _createDynamicBtn(false)
: null,
leadingWidth: 50,
toolbarHeight: 50,
title: SizedBox(
height: 50,
child: TabBar(
controller: _dynamicsController.tabController,
isScrollable: true,
dividerColor: Colors.transparent,
dividerHeight: 0,
tabAlignment: TabAlignment.center,
indicatorColor: Theme.of(context).colorScheme.primary,
labelColor: Theme.of(context).colorScheme.primary,
unselectedLabelColor: Theme.of(context).colorScheme.onSurface,
labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
tabs:
DynamicsType.values.map((e) => Tab(text: e.labels)).toList(),
onTap: (index) {
if (!_dynamicsController.tabController.indexIsChanging) {
_dynamicsController.animateToTop();
}
},
),
resizeToAvoidBottomInset: false,
appBar: AppBar(
leading: upPanelPosition == UpPanelPosition.rightDrawer
? _createDynamicBtn(false)
: null,
leadingWidth: 50,
toolbarHeight: 50,
title: SizedBox(
height: 50,
child: TabBar(
controller: _dynamicsController.tabController,
isScrollable: true,
dividerColor: Colors.transparent,
dividerHeight: 0,
tabAlignment: TabAlignment.center,
indicatorColor: Theme.of(context).colorScheme.primary,
labelColor: Theme.of(context).colorScheme.primary,
unselectedLabelColor: Theme.of(context).colorScheme.onSurface,
labelStyle:
TabBarTheme.of(context).labelStyle?.copyWith(fontSize: 13) ??
const TextStyle(fontSize: 13),
tabs: DynamicsType.values.map((e) => Tab(text: e.labels)).toList(),
onTap: (index) {
if (!_dynamicsController.tabController.indexIsChanging) {
_dynamicsController.animateToTop();
}
},
),
actions: upPanelPosition == UpPanelPosition.rightDrawer
? null
: [_createDynamicBtn()],
),
drawer: upPanelPosition == UpPanelPosition.leftDrawer
? SafeArea(child: upPanelPart())
: null,
drawerEnableOpenDragGesture: true,
endDrawer: upPanelPosition == UpPanelPosition.rightDrawer
? SafeArea(child: upPanelPart())
: null,
endDrawerEnableOpenDragGesture: true,
body: Row(children: [
actions: upPanelPosition == UpPanelPosition.rightDrawer
? null
: [_createDynamicBtn()],
),
drawer: upPanelPosition == UpPanelPosition.leftDrawer
? SafeArea(child: upPanelPart())
: null,
drawerEnableOpenDragGesture: true,
endDrawer: upPanelPosition == UpPanelPosition.rightDrawer
? SafeArea(child: upPanelPart())
: null,
endDrawerEnableOpenDragGesture: true,
body: Row(
children: [
if (upPanelPosition == UpPanelPosition.leftFixed) upPanelPart(),
Expanded(
child: tabBarView(
controller: _dynamicsController.tabController,
children: _dynamicsController.tabsPageList,
)),
child: tabBarView(
controller: _dynamicsController.tabController,
children: _dynamicsController.tabsPageList,
),
),
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(),
),
),
body: tabBarView(
controller: _tabController,
children: _FavType.values
.map((item) => SafeArea(
top: false,
bottom: false,
child: item.page,
))
.toList(),
body: SafeArea(
top: false,
bottom: false,
child: tabBarView(
controller: _tabController,
children: _FavType.values.map((item) => item.page).toList(),
),
),
);
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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