Skip to content

Commit

Permalink
style(*): code clean
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhuJHua committed Oct 27, 2024
1 parent 61d79c1 commit 0947c45
Show file tree
Hide file tree
Showing 54 changed files with 160 additions and 436 deletions.
7 changes: 3 additions & 4 deletions lib/common/values/media_type.dart
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
enum MediaType{

enum MediaType {
image(0, 'image'),
audio(1, 'audio'),
video(2,'video');
video(2, 'video');

const MediaType(this.number, this.value);

final int number;
final String value;

static MediaType getType(int number) => MediaType.values.firstWhere((e) => e.number == number);
}
}
12 changes: 1 addition & 11 deletions lib/components/audio_player/audio_player_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class AudioPlayerLogic extends GetxController with GetSingleTickerProviderStateM
late final EditLogic editLogic = Bind.find<EditLogic>();

@override
void onInit() {
// TODO: implement onInit
void onReady() {
audioPlayer.eventStream.listen((event) {
//读取时间完成
if (event.eventType == AudioEventType.duration) {
Expand All @@ -34,20 +33,11 @@ class AudioPlayerLogic extends GetxController with GetSingleTickerProviderStateM
state.currentDuration.value = duration;
}
});

super.onInit();
}

@override
void onReady() {
// TODO: implement onReady

super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
animationController.dispose();
audioPlayer.dispose();
super.onClose();
Expand Down
2 changes: 1 addition & 1 deletion lib/components/audio_player/audio_player_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import 'package:get/get.dart';
import 'audio_player_logic.dart';

class AudioPlayerComponent extends StatelessWidget {
const AudioPlayerComponent({super.key, required this.path, this.isEdit = false});
const AudioPlayerComponent({super.key, required this.path, this.isEdit = false});

final String path;

Expand Down
2 changes: 0 additions & 2 deletions lib/components/category_add/category_add_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,12 @@ class CategoryAddLogic extends GetxController {

@override
void onReady() {
// TODO: implement onReady
getCategory();
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
textEditingController.dispose();
super.onClose();
}
Expand Down
17 changes: 2 additions & 15 deletions lib/components/color_dialog/color_dialog_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,14 @@ class ColorDialogLogic extends GetxController {
late SettingLogic settingLogic = Bind.find<SettingLogic>();

@override
void onInit() async {
// TODO: implement onInit
void onReady() async {
//如果支持系统颜色,获取系统颜色
if (state.supportDynamic.value) {
state.systemColor.value = await Utils().themeUtil.getDynamicColor();
}
super.onInit();
}

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
super.onClose();
}


//更改主题色
Future<void> changeSeedColor(index) async {
await Utils().prefUtil.setValue<int>('color', index);
Expand Down
27 changes: 8 additions & 19 deletions lib/components/dashboard/dashboard_logic.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:get/get.dart';
import 'package:mood_diary/router/app_routes.dart';
Expand All @@ -9,19 +11,12 @@ class DashboardLogic extends GetxController {
final DashboardState state = DashboardState();

@override
void onInit() {
// TODO: implement onInit
getUseTime();
getDiaryCount();
getMoodAndWeatherByRange(state.dateRange[0], state.dateRange[1]);
getCountContent();
getCategoryCount();
super.onInit();
}

@override
void onReady() {
// TODO: implement onReady
void onReady() async {
unawaited(getUseTime());
unawaited(getDiaryCount());
unawaited(getMoodAndWeatherByRange(state.dateRange[0], state.dateRange[1]));
unawaited(getCountContent());
unawaited(getCategoryCount());
super.onReady();
}

Expand Down Expand Up @@ -81,10 +76,4 @@ class DashboardLogic extends GetxController {
await Get.toNamed(AppRoutes.categoryManagerPage);
await getCategoryCount();
}

@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}
14 changes: 0 additions & 14 deletions lib/components/diary_tab_view/diary_tab_view_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,12 @@ class DiaryTabViewLogic extends GetxController {

DiaryTabViewLogic({required this.categoryId});

@override
void onInit() {
// TODO: implement onInit

super.onInit();
}

@override
void onReady() async {
await getDiary();
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose

super.onClose();
}

Future<void> getDiary() async {
state.isFetching.value = true;
state.diaryList.value = await Utils().isarUtil.getDiaryByCategory(categoryId, 0, state.initLen);
Expand Down
3 changes: 0 additions & 3 deletions lib/components/diary_tab_view/diary_tab_view_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@ class DiaryTabViewState {

late RxBool isFetching;


//首次加载的个数
late int initLen;

//分页的个数
late int pageLen;



DiaryTabViewState() {
diaryList = <Diary>[].obs;
isFetching = false.obs;
Expand Down
7 changes: 0 additions & 7 deletions lib/components/login_form/login_form_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,8 @@ class LoginFormLogic extends GetxController {
final FocusNode emailFocusNode = FocusNode();
final FocusNode passwordFocusNode = FocusNode();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
emailFocusNode.dispose();
passwordFocusNode.dispose();

Expand Down
10 changes: 0 additions & 10 deletions lib/components/mood_icon/mood_icon_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,5 @@ import 'mood_icon_state.dart';
class MoodIconLogic extends GetxController {
final MoodIconState state = MoodIconState();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
super.onClose();
}
}
2 changes: 0 additions & 2 deletions lib/components/record_sheet/record_sheet_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@ class RecordSheetLogic extends GetxController with GetTickerProviderStateMixin {

@override
void onReady() {
// TODO: implement onReady
//启动监听
listenAmplitude();
super.onReady();
}

@override
void onClose() async {
// TODO: implement onClose
if (state.isStop == false) {
await audioRecorder.cancel();
}
Expand Down
4 changes: 0 additions & 4 deletions lib/components/record_sheet/record_sheet_state.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'package:get/get.dart';

class RecordSheetState {

late Rx<Duration> durationTime;
late RxBool isRecording;
late RxBool isStarted;
Expand All @@ -11,10 +10,7 @@ class RecordSheetState {
late double maxWidth;
late bool isStop;



RecordSheetState() {

isRecording = false.obs;
isStarted = false.obs;
fileName = '';
Expand Down
8 changes: 0 additions & 8 deletions lib/components/register_form/register_form_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,8 @@ class RegisterFormLogic extends GetxController {
final FocusNode rePasswordFocusNode = FocusNode();
late final loginLogic = Bind.find<LoginLogic>();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose

emailFocusNode.dispose();
passwordFocusNode.dispose();
rePasswordFocusNode.dispose();
Expand Down
7 changes: 0 additions & 7 deletions lib/components/remove_password/remove_password_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,8 @@ class RemovePasswordLogic extends GetxController with GetSingleTickerProviderSta

late final settingLogic = Bind.find<SettingLogic>();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
animationController.dispose();
super.onClose();
}
Expand Down
12 changes: 0 additions & 12 deletions lib/components/search_card/search_card_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,6 @@ import 'search_card_state.dart';
class SearchCardLogic extends GetxController {
final SearchCardState state = SearchCardState();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
super.onClose();
}

//选中卡片后跳转到详情页,直接携带Diary作为参数
Future<void> toDiaryPage(Diary diary) async {
await Get.toNamed(AppRoutes.diaryPage, arguments: [diary, false]);
Expand Down
7 changes: 0 additions & 7 deletions lib/components/search_sheet/search_sheet_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,8 @@ class SearchSheetLogic extends GetxController {
late TextEditingController textEditingController = TextEditingController();
late FocusNode focusNode = FocusNode();

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
textEditingController.dispose();
focusNode.dispose();
super.onClose();
Expand Down
14 changes: 0 additions & 14 deletions lib/components/set_password/set_password_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,8 @@ class SetPasswordLogic extends GetxController with GetSingleTickerProviderStateM

late final settingLogic = Bind.find<SettingLogic>();

@override
void onInit() {
// TODO: implement onInit

super.onInit();
}

@override
void onReady() {
// TODO: implement onReady
super.onReady();
}

@override
void onClose() {
// TODO: implement onClose
animationController.dispose();
super.onClose();
}
Expand Down
16 changes: 1 addition & 15 deletions lib/components/side_bar/side_bar_logic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ class SideBarLogic extends GetxController {
late HomeLogic homeLogic = Bind.find<HomeLogic>();

@override
void onInit() {
// TODO: implement onInit
void onReady() {
getHitokoto();
getImage();
getInfo();
getWeather();
super.onInit();
}

@override
void onReady() {
// TODO: implement onReady

super.onReady();
}

Expand All @@ -46,12 +38,6 @@ class SideBarLogic extends GetxController {
}
}

@override
void onClose() {
// TODO: implement onClose
super.onClose();
}

Future<void> getImage() async {
var url = await Utils().cacheUtil.getCacheList('bingImage', Api().updateImageUrl, maxAgeMillis: 6 * 60 * 60000);
if (url != null) {
Expand Down
Loading

0 comments on commit 0947c45

Please sign in to comment.