Skip to content

Commit

Permalink
Fix several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert-Stackflow committed Nov 10, 2024
1 parent 2b05113 commit 2a53920
Show file tree
Hide file tree
Showing 74 changed files with 1,278 additions and 872 deletions.
9 changes: 4 additions & 5 deletions lib/Resources/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'styles.dart';
class MyTheme {
MyTheme._();

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

static ThemeData getTheme({required bool isDarkMode}) {
return ThemeData(
Expand Down Expand Up @@ -227,10 +227,9 @@ class MyTheme {
}

static Color get background {
return scaffoldBackgroundColor;
// return Utils.currentBrightness(rootContext) == Brightness.light
// ? Theme.of(rootContext).scaffoldBackgroundColor
// : Theme.of(rootContext).canvasColor;
return Utils.currentBrightness(rootContext) == Brightness.light
? scaffoldBackgroundColor
: scaffoldBackgroundColor;
}

static Color get itemBackground {
Expand Down
6 changes: 0 additions & 6 deletions lib/Screens/Info/collection_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ class _CollectionScreenState extends State<CollectionScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
if (widget.nested) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down
67 changes: 12 additions & 55 deletions lib/Screens/Info/favorite_folder_detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import '../../Api/user_api.dart';
import '../../Models/history_response.dart';
import '../../Models/post_detail_response.dart';
import '../../Resources/theme.dart';
import '../../Utils/constant.dart';
import '../../Utils/enums.dart';
import '../../Utils/hive_util.dart';
import '../../Utils/ilogger.dart';
Expand Down Expand Up @@ -41,8 +40,6 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
SimpleBlogInfo? _creatorInfo;
final List<FavoritePostDetailData> _posts = [];
final List<ArchiveData> _archiveDataList = [];
final FavoriteFolderDetailLayoutMode _layoutMode =
FavoriteFolderDetailLayoutMode.nineGrid;
bool _loading = false;
final EasyRefreshController _refreshController = EasyRefreshController();
bool _noMore = false;
Expand Down Expand Up @@ -129,29 +126,26 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
return Scaffold(
backgroundColor: MyTheme.getBackground(context),
appBar: _buildAppBar(),
body: EasyRefresh(
body: EasyRefresh.builder(
refreshOnStart: true,
controller: _refreshController,
onRefresh: _onRefresh,
onLoad: _onLoad,
triggerAxis: Axis.vertical,
child: _buildBody(),
childBuilder: (context, physics) =>
_archiveDataList.isNotEmpty && _posts.isNotEmpty
? _buildNineGridGroup(physics)
: ItemBuilder.buildEmptyPlaceholder(
context: context,
text: S.current.noFavorite,
physics: physics,
shrinkWrap: false,
),
),
);
}

Widget _buildBody() {
switch (_layoutMode) {
case FavoriteFolderDetailLayoutMode.list:
return _buildList();
case FavoriteFolderDetailLayoutMode.nineGrid:
return _buildNineGridGroup();
case FavoriteFolderDetailLayoutMode.flow:
return _buildFlow();
}
}

Widget _buildNineGridGroup() {
Widget _buildNineGridGroup(ScrollPhysics physics) {
List<Widget> widgets = [];
int startIndex = 0;
for (var e in _archiveDataList) {
Expand All @@ -174,6 +168,7 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
}
return ListView(
cacheExtent: 9999,
physics: physics,
children: widgets,
);
}
Expand Down Expand Up @@ -216,49 +211,11 @@ class _FavoriteFolderDetailScreenState extends State<FavoriteFolderDetailScreen>
);
}

Widget _buildFlow() {
return emptyWidget;
}

Widget _buildList() {
return emptyWidget;
}

PreferredSizeWidget _buildAppBar() {
IconData icon = Icons.transform_rounded;
switch (_layoutMode) {
case FavoriteFolderDetailLayoutMode.list:
icon = Icons.list_rounded;
break;
case FavoriteFolderDetailLayoutMode.nineGrid:
icon = Icons.grid_on_rounded;
break;
case FavoriteFolderDetailLayoutMode.flow:
icon = Icons.article_outlined;
break;
}
return ItemBuilder.buildResponsiveAppBar(
context: context,
showBack: true,
title: _favoriteFolder?.name ?? S.current.favoriteFolderDetail,
actions: [
// ItemBuilder.buildIconButton(
// context: context,
// icon: Icon(icon, color: Theme.of(context).iconTheme.color),
// onTap: () {
// _layoutMode = FavoriteFolderDetailLayoutMode.values[
// (_layoutMode.index + 1) %
// FavoriteFolderDetailLayoutMode.values.length];
// setState(() {});
// }),
// const SizedBox(width: 5),
// ItemBuilder.buildIconButton(
// context: context,
// icon: Icon(Icons.more_vert_rounded,
// color: Theme.of(context).iconTheme.color),
// onTap: () {}),
const SizedBox(width: 5),
],
);
}
}
7 changes: 0 additions & 7 deletions lib/Screens/Info/favorite_folder_list_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,6 @@ class _FavoriteFolderListScreenState extends State<FavoriteFolderListScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
}

Expand Down Expand Up @@ -310,7 +304,6 @@ class _FavoriteFolderListScreenState extends State<FavoriteFolderListScreen>
Icon(Icons.add_rounded, color: Theme.of(context).iconTheme.color),
onTap: handleAdd,
),
const SizedBox(width: 5),
],
);
}
Expand Down
6 changes: 0 additions & 6 deletions lib/Screens/Info/following_follower_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class _FollowingFollowerScreenState extends State<FollowingFollowerScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
total = widget.total;
super.initState();
}
Expand Down
17 changes: 1 addition & 16 deletions lib/Screens/Info/grain_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,6 @@ class _GrainScreenState extends State<GrainScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
if (widget.nested) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down Expand Up @@ -289,16 +283,7 @@ class _GrainScreenState extends State<GrainScreen>
context: context,
showBack: true,
title: S.current.myGrains,
actions: [
ItemBuilder.buildBlankIconButton(context),
const SizedBox(width: 5),
// ItemBuilder.buildIconButton(
// context: context,
// icon: Icon(Icons.more_vert_rounded,
// color: Theme.of(context).iconTheme.color),
// onTap: () {}),
// const SizedBox(width: 5),
],
actions: [ItemBuilder.buildBlankIconButton(context)],
);
}
}
17 changes: 5 additions & 12 deletions lib/Screens/Info/history_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,6 @@ class _HistoryScreenState extends State<HistoryScreen>
bool _noMore = false;
InitPhase _initPhase = InitPhase.successful;

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
}

_fetchHistory({bool refresh = false}) async {
if (_loading) return;
if (refresh) _noMore = false;
Expand Down Expand Up @@ -234,7 +223,6 @@ class _HistoryScreenState extends State<HistoryScreen>
onTap: () {
BottomSheetBuilder.showContextMenu(context, _buildMoreButtons());
}),
const SizedBox(width: 5),
],
);
}
Expand Down Expand Up @@ -264,6 +252,7 @@ class _HistoryScreenState extends State<HistoryScreen>
buttonConfigs: [
ContextMenuButtonConfig(
S.current.clearMyHistory,
icon: const Icon(Icons.clear_rounded),
onPressed: () {
DialogBuilder.showConfirmDialog(
context,
Expand All @@ -288,6 +277,7 @@ class _HistoryScreenState extends State<HistoryScreen>
),
ContextMenuButtonConfig(
S.current.clearInvalidContent,
icon: const Icon(Icons.delete_outline_rounded),
onPressed: () async {
UserApi.deleteInvalidHistory(blogId: await HiveUtil.getUserId())
.then((value) {
Expand All @@ -305,6 +295,9 @@ class _HistoryScreenState extends State<HistoryScreen>
_recordHistory == 1
? S.current.closeMyHistory
: S.current.openMyHistory,
icon: Icon(_recordHistory == 1
? Icons.history_toggle_off_rounded
: Icons.history_toggle_off_rounded),
onPressed: () {
HiveUtil.getUserInfo().then((blogInfo) async {
close() {
Expand Down
8 changes: 1 addition & 7 deletions lib/Screens/Info/like_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ class _LikeScreenState extends State<LikeScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
if (widget.nested) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down Expand Up @@ -277,7 +271,6 @@ class _LikeScreenState extends State<LikeScreen>
onTap: () {
BottomSheetBuilder.showContextMenu(context, _buildMoreButtons());
}),
const SizedBox(width: 5),
],
);
}
Expand All @@ -287,6 +280,7 @@ class _LikeScreenState extends State<LikeScreen>
buttonConfigs: [
ContextMenuButtonConfig(
S.current.clearInvalidContent,
icon: const Icon(Icons.delete_outline_rounded),
onPressed: () async {
UserApi.deleteInvalidLike(blogId: await HiveUtil.getUserId())
.then((value) {
Expand Down
14 changes: 0 additions & 14 deletions lib/Screens/Info/post_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,6 @@ class _PostScreenState extends State<PostScreen>

@override
void initState() {
if (Platform.isAndroid) {
SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.dark);
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
}
super.initState();
if (widget.nested) {
WidgetsBinding.instance.addPostFrameCallback((_) {
Expand Down Expand Up @@ -283,14 +277,6 @@ class _PostScreenState extends State<PostScreen>
context: context,
showBack: true,
title: S.current.myPosts,
actions: [
// ItemBuilder.buildIconButton(
// context: context,
// icon: Icon(Icons.more_vert_rounded,
// color: Theme.of(context).iconTheme.color),
// onTap: () {}),
// const SizedBox(width: 5),
],
);
}
}
Loading

0 comments on commit 2a53920

Please sign in to comment.