Skip to content

Commit 2a53920

Browse files
Fix several bugs
1 parent 2b05113 commit 2a53920

File tree

74 files changed

+1278
-872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+1278
-872
lines changed

lib/Resources/theme.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import 'styles.dart';
99
class MyTheme {
1010
MyTheme._();
1111

12-
bool get isDarkMode => Theme.of(rootContext).brightness == Brightness.dark;
12+
static bool get isDarkMode => Theme.of(rootContext).brightness == Brightness.dark;
1313

1414
static ThemeData getTheme({required bool isDarkMode}) {
1515
return ThemeData(
@@ -227,10 +227,9 @@ class MyTheme {
227227
}
228228

229229
static Color get background {
230-
return scaffoldBackgroundColor;
231-
// return Utils.currentBrightness(rootContext) == Brightness.light
232-
// ? Theme.of(rootContext).scaffoldBackgroundColor
233-
// : Theme.of(rootContext).canvasColor;
230+
return Utils.currentBrightness(rootContext) == Brightness.light
231+
? scaffoldBackgroundColor
232+
: scaffoldBackgroundColor;
234233
}
235234

236235
static Color get itemBackground {

lib/Screens/Info/collection_screen.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ class _CollectionScreenState extends State<CollectionScreen>
5858

5959
@override
6060
void initState() {
61-
if (Platform.isAndroid) {
62-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
63-
statusBarColor: Colors.transparent,
64-
statusBarIconBrightness: Brightness.dark);
65-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
66-
}
6761
super.initState();
6862
if (widget.nested) {
6963
WidgetsBinding.instance.addPostFrameCallback((_) {

lib/Screens/Info/favorite_folder_detail_screen.dart

Lines changed: 12 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import '../../Api/user_api.dart';
66
import '../../Models/history_response.dart';
77
import '../../Models/post_detail_response.dart';
88
import '../../Resources/theme.dart';
9-
import '../../Utils/constant.dart';
109
import '../../Utils/enums.dart';
1110
import '../../Utils/hive_util.dart';
1211
import '../../Utils/ilogger.dart';
@@ -41,8 +40,6 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
4140
SimpleBlogInfo? _creatorInfo;
4241
final List<FavoritePostDetailData> _posts = [];
4342
final List<ArchiveData> _archiveDataList = [];
44-
final FavoriteFolderDetailLayoutMode _layoutMode =
45-
FavoriteFolderDetailLayoutMode.nineGrid;
4643
bool _loading = false;
4744
final EasyRefreshController _refreshController = EasyRefreshController();
4845
bool _noMore = false;
@@ -129,29 +126,26 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
129126
return Scaffold(
130127
backgroundColor: MyTheme.getBackground(context),
131128
appBar: _buildAppBar(),
132-
body: EasyRefresh(
129+
body: EasyRefresh.builder(
133130
refreshOnStart: true,
134131
controller: _refreshController,
135132
onRefresh: _onRefresh,
136133
onLoad: _onLoad,
137134
triggerAxis: Axis.vertical,
138-
child: _buildBody(),
135+
childBuilder: (context, physics) =>
136+
_archiveDataList.isNotEmpty && _posts.isNotEmpty
137+
? _buildNineGridGroup(physics)
138+
: ItemBuilder.buildEmptyPlaceholder(
139+
context: context,
140+
text: S.current.noFavorite,
141+
physics: physics,
142+
shrinkWrap: false,
143+
),
139144
),
140145
);
141146
}
142147

143-
Widget _buildBody() {
144-
switch (_layoutMode) {
145-
case FavoriteFolderDetailLayoutMode.list:
146-
return _buildList();
147-
case FavoriteFolderDetailLayoutMode.nineGrid:
148-
return _buildNineGridGroup();
149-
case FavoriteFolderDetailLayoutMode.flow:
150-
return _buildFlow();
151-
}
152-
}
153-
154-
Widget _buildNineGridGroup() {
148+
Widget _buildNineGridGroup(ScrollPhysics physics) {
155149
List<Widget> widgets = [];
156150
int startIndex = 0;
157151
for (var e in _archiveDataList) {
@@ -174,6 +168,7 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
174168
}
175169
return ListView(
176170
cacheExtent: 9999,
171+
physics: physics,
177172
children: widgets,
178173
);
179174
}
@@ -216,49 +211,11 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
216211
);
217212
}
218213

219-
Widget _buildFlow() {
220-
return emptyWidget;
221-
}
222-
223-
Widget _buildList() {
224-
return emptyWidget;
225-
}
226-
227214
PreferredSizeWidget _buildAppBar() {
228-
IconData icon = Icons.transform_rounded;
229-
switch (_layoutMode) {
230-
case FavoriteFolderDetailLayoutMode.list:
231-
icon = Icons.list_rounded;
232-
break;
233-
case FavoriteFolderDetailLayoutMode.nineGrid:
234-
icon = Icons.grid_on_rounded;
235-
break;
236-
case FavoriteFolderDetailLayoutMode.flow:
237-
icon = Icons.article_outlined;
238-
break;
239-
}
240215
return ItemBuilder.buildResponsiveAppBar(
241216
context: context,
242217
showBack: true,
243218
title: _favoriteFolder?.name ?? S.current.favoriteFolderDetail,
244-
actions: [
245-
// ItemBuilder.buildIconButton(
246-
// context: context,
247-
// icon: Icon(icon, color: Theme.of(context).iconTheme.color),
248-
// onTap: () {
249-
// _layoutMode = FavoriteFolderDetailLayoutMode.values[
250-
// (_layoutMode.index + 1) %
251-
// FavoriteFolderDetailLayoutMode.values.length];
252-
// setState(() {});
253-
// }),
254-
// const SizedBox(width: 5),
255-
// ItemBuilder.buildIconButton(
256-
// context: context,
257-
// icon: Icon(Icons.more_vert_rounded,
258-
// color: Theme.of(context).iconTheme.color),
259-
// onTap: () {}),
260-
const SizedBox(width: 5),
261-
],
262219
);
263220
}
264221
}

lib/Screens/Info/favorite_folder_list_screen.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@ class _FavoriteFolderListScreenState extends State<FavoriteFolderListScreen>
4343

4444
@override
4545
void initState() {
46-
if (Platform.isAndroid) {
47-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
48-
statusBarColor: Colors.transparent,
49-
statusBarIconBrightness: Brightness.dark);
50-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
51-
}
5246
super.initState();
5347
}
5448

@@ -310,7 +304,6 @@ class _FavoriteFolderListScreenState extends State<FavoriteFolderListScreen>
310304
Icon(Icons.add_rounded, color: Theme.of(context).iconTheme.color),
311305
onTap: handleAdd,
312306
),
313-
const SizedBox(width: 5),
314307
],
315308
);
316309
}

lib/Screens/Info/following_follower_screen.dart

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,6 @@ class _FollowingFollowerScreenState extends State<FollowingFollowerScreen>
5555

5656
@override
5757
void initState() {
58-
if (Platform.isAndroid) {
59-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
60-
statusBarColor: Colors.transparent,
61-
statusBarIconBrightness: Brightness.dark);
62-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
63-
}
6458
total = widget.total;
6559
super.initState();
6660
}

lib/Screens/Info/grain_screen.dart

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,6 @@ class _GrainScreenState extends State<GrainScreen>
5858

5959
@override
6060
void initState() {
61-
if (Platform.isAndroid) {
62-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
63-
statusBarColor: Colors.transparent,
64-
statusBarIconBrightness: Brightness.dark);
65-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
66-
}
6761
super.initState();
6862
if (widget.nested) {
6963
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -289,16 +283,7 @@ class _GrainScreenState extends State<GrainScreen>
289283
context: context,
290284
showBack: true,
291285
title: S.current.myGrains,
292-
actions: [
293-
ItemBuilder.buildBlankIconButton(context),
294-
const SizedBox(width: 5),
295-
// ItemBuilder.buildIconButton(
296-
// context: context,
297-
// icon: Icon(Icons.more_vert_rounded,
298-
// color: Theme.of(context).iconTheme.color),
299-
// onTap: () {}),
300-
// const SizedBox(width: 5),
301-
],
286+
actions: [ItemBuilder.buildBlankIconButton(context)],
302287
);
303288
}
304289
}

lib/Screens/Info/history_screen.dart

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,6 @@ class _HistoryScreenState extends State<HistoryScreen>
4444
bool _noMore = false;
4545
InitPhase _initPhase = InitPhase.successful;
4646

47-
@override
48-
void initState() {
49-
if (Platform.isAndroid) {
50-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
51-
statusBarColor: Colors.transparent,
52-
statusBarIconBrightness: Brightness.dark);
53-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
54-
}
55-
super.initState();
56-
}
57-
5847
_fetchHistory({bool refresh = false}) async {
5948
if (_loading) return;
6049
if (refresh) _noMore = false;
@@ -234,7 +223,6 @@ class _HistoryScreenState extends State<HistoryScreen>
234223
onTap: () {
235224
BottomSheetBuilder.showContextMenu(context, _buildMoreButtons());
236225
}),
237-
const SizedBox(width: 5),
238226
],
239227
);
240228
}
@@ -264,6 +252,7 @@ class _HistoryScreenState extends State<HistoryScreen>
264252
buttonConfigs: [
265253
ContextMenuButtonConfig(
266254
S.current.clearMyHistory,
255+
icon: const Icon(Icons.clear_rounded),
267256
onPressed: () {
268257
DialogBuilder.showConfirmDialog(
269258
context,
@@ -288,6 +277,7 @@ class _HistoryScreenState extends State<HistoryScreen>
288277
),
289278
ContextMenuButtonConfig(
290279
S.current.clearInvalidContent,
280+
icon: const Icon(Icons.delete_outline_rounded),
291281
onPressed: () async {
292282
UserApi.deleteInvalidHistory(blogId: await HiveUtil.getUserId())
293283
.then((value) {
@@ -305,6 +295,9 @@ class _HistoryScreenState extends State<HistoryScreen>
305295
_recordHistory == 1
306296
? S.current.closeMyHistory
307297
: S.current.openMyHistory,
298+
icon: Icon(_recordHistory == 1
299+
? Icons.history_toggle_off_rounded
300+
: Icons.history_toggle_off_rounded),
308301
onPressed: () {
309302
HiveUtil.getUserInfo().then((blogInfo) async {
310303
close() {

lib/Screens/Info/like_screen.dart

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,6 @@ class _LikeScreenState extends State<LikeScreen>
6161

6262
@override
6363
void initState() {
64-
if (Platform.isAndroid) {
65-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
66-
statusBarColor: Colors.transparent,
67-
statusBarIconBrightness: Brightness.dark);
68-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
69-
}
7064
super.initState();
7165
if (widget.nested) {
7266
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -277,7 +271,6 @@ class _LikeScreenState extends State<LikeScreen>
277271
onTap: () {
278272
BottomSheetBuilder.showContextMenu(context, _buildMoreButtons());
279273
}),
280-
const SizedBox(width: 5),
281274
],
282275
);
283276
}
@@ -287,6 +280,7 @@ class _LikeScreenState extends State<LikeScreen>
287280
buttonConfigs: [
288281
ContextMenuButtonConfig(
289282
S.current.clearInvalidContent,
283+
icon: const Icon(Icons.delete_outline_rounded),
290284
onPressed: () async {
291285
UserApi.deleteInvalidLike(blogId: await HiveUtil.getUserId())
292286
.then((value) {

lib/Screens/Info/post_screen.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,6 @@ class _PostScreenState extends State<PostScreen>
5656

5757
@override
5858
void initState() {
59-
if (Platform.isAndroid) {
60-
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
61-
statusBarColor: Colors.transparent,
62-
statusBarIconBrightness: Brightness.dark);
63-
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
64-
}
6559
super.initState();
6660
if (widget.nested) {
6761
WidgetsBinding.instance.addPostFrameCallback((_) {
@@ -283,14 +277,6 @@ class _PostScreenState extends State<PostScreen>
283277
context: context,
284278
showBack: true,
285279
title: S.current.myPosts,
286-
actions: [
287-
// ItemBuilder.buildIconButton(
288-
// context: context,
289-
// icon: Icon(Icons.more_vert_rounded,
290-
// color: Theme.of(context).iconTheme.color),
291-
// onTap: () {}),
292-
// const SizedBox(width: 5),
293-
],
294280
);
295281
}
296282
}

0 commit comments

Comments
 (0)