Skip to content

Commit

Permalink
refactor(*): optimize the color scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuJHua committed Oct 1, 2024
1 parent 325d392 commit 555d66f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 37 deletions.
1 change: 1 addition & 0 deletions lib/components/audio_player/audio_player_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AudioPlayerComponent extends StatelessWidget {
)),
Expanded(
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
Obx(() {
return Slider(
Expand Down
2 changes: 1 addition & 1 deletion lib/components/dashboard/dashboard_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class DashboardLogic extends GetxController {
}

Future<void> getDiaryCount() async {
int count = await Utils().isarUtil.countDiaries();
int count = await Utils().isarUtil.countShowDiary();
state.diaryCount.value = count.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CalendarDiaryCardComponent extends StatelessWidget with BasicCardLogic {
await toDiaryInCalendar(diary);
},
child: Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class LargeDiaryCardComponent extends StatelessWidget with BasicCardLogic {

final Diary diary;


@override
Widget build(BuildContext context) {
final colorScheme = Theme.of(context).colorScheme;
Expand All @@ -37,7 +36,7 @@ class LargeDiaryCardComponent extends StatelessWidget with BasicCardLogic {
await toDiary(diary);
},
child: Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: [
if (diary.imageName.isNotEmpty) ...[buildImage()],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class SmallDiaryCardComponent extends StatelessWidget with BasicCardLogic {
await toDiary(diary);
},
child: Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: SizedBox(
height: 122.0,
child: Row(
Expand Down
42 changes: 17 additions & 25 deletions lib/components/diary_tab_view/diary_tab_view_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'package:get/get.dart';
import 'package:mood_diary/common/values/view_mode.dart';
import 'package:mood_diary/components/diary_card/large_diary_card/large_diary_card_view.dart';
import 'package:mood_diary/components/diary_card/small_diary_card/small_diary_card_view.dart';
import 'package:sliver_tools/sliver_tools.dart';

import 'diary_tab_view_logic.dart';

Expand Down Expand Up @@ -57,16 +58,6 @@ class DiaryTabViewComponent extends StatelessWidget {
);
}

Widget buildCustomScrollView({required Widget sliver}) {
return CustomScrollView(
key: UniqueKey(),
slivers: [
SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
SliverPadding(padding: const EdgeInsets.all(4.0), sliver: sliver),
],
);
}

return GetBuilder<DiaryTabViewLogic>(
assignId: true,
init: logic,
Expand All @@ -76,21 +67,22 @@ class DiaryTabViewComponent extends StatelessWidget {
return Stack(
children: [
buildPlaceHolder(),
Obx(() {
return !state.isFetching.value
? AnimatedSwitcher(
duration: const Duration(milliseconds: 500),
child: switch (logic.diaryLogic.state.viewModeType.value) {
ViewModeType.list => buildCustomScrollView(sliver: Obx(() {
return buildList();
})),
ViewModeType.grid => buildCustomScrollView(sliver: Obx(() {
return buildGrid();
})),
},
)
: const SizedBox.shrink();
}),
CustomScrollView(
slivers: [
SliverOverlapInjector(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context)),
SliverPadding(
padding: const EdgeInsets.all(4.0),
sliver: Obx(() {
return SliverAnimatedSwitcher(
duration: const Duration(milliseconds: 400),
child: switch (logic.diaryLogic.state.viewModeType.value) {
ViewModeType.list => buildList(),
ViewModeType.grid => buildGrid(),
},
);
})),
],
),
],
);
});
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/about/about_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class AboutPage extends StatelessWidget {
children: [
buildLogoTitle(),
Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: ListTile.divideTiles(tiles: [
ListTile(
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/home/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ class HomePage extends StatelessWidget {
? AnimatedBuilder(
animation: logic.barAnimation,
builder: (context, child) {
return SizedBox(
return Container(
height: state.navigatorBarHeight * logic.barAnimation.value,
decoration: BoxDecoration(border: Border(top: BorderSide(color: colorScheme.outline, width: 0.2))),
child: child,
);
},
Expand Down Expand Up @@ -185,7 +186,6 @@ class HomePage extends StatelessWidget {
],
selectedIndex: state.navigatorIndex.value,
height: state.navigatorBarHeight,
backgroundColor: colorScheme.surface,
onDestinationSelected: (index) {
logic.changeNavigator(index);
},
Expand Down
8 changes: 4 additions & 4 deletions lib/pages/home/setting/setting_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SettingPage extends StatelessWidget {
),
),
Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: [
ListTile(
Expand Down Expand Up @@ -141,7 +141,7 @@ class SettingPage extends StatelessWidget {
),
),
Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: [
ListTile(
Expand Down Expand Up @@ -412,7 +412,7 @@ class SettingPage extends StatelessWidget {
),
),
Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: [
Obx(() {
Expand Down Expand Up @@ -490,7 +490,7 @@ class SettingPage extends StatelessWidget {
),
),
Card.filled(
color: colorScheme.surfaceContainer,
color: colorScheme.surfaceContainerLow,
child: Column(
children: [
ListTile(
Expand Down

0 comments on commit 555d66f

Please sign in to comment.