From e32bb156fe7f0ca1d745754b012dadeef097c484 Mon Sep 17 00:00:00 2001 From: ZhuJHua <1624109111@qq.com> Date: Sun, 16 Mar 2025 20:47:47 +0800 Subject: [PATCH] chore(deps): remove unnecessary dependencies --- lib/components/base/loading.dart | 61 ++++++ .../category_choice_sheet_view.dart | 110 +++++----- .../diary_tab_view/diary_tab_view_view.dart | 22 +- lib/components/loading/loading.dart | 104 ---------- .../sync_dash_board/sync_dash_board_view.dart | 39 ++-- .../web_dav_dashboard_view.dart | 4 +- .../video_player/video_player_view.dart | 15 +- lib/main.dart | 7 +- .../category_manager_view.dart | 6 +- lib/pages/font/font_view.dart | 193 ++++++++---------- lib/pages/home/calendar/calendar_view.dart | 7 +- lib/pages/home/diary/diary_view.dart | 11 +- lib/pages/home/media/media_view.dart | 7 +- lib/presentation/isar.dart | 188 ++++++++++------- lib/utils/theme_util.dart | 8 + macos/Flutter/GeneratedPluginRegistrant.swift | 4 - .../flutter/generated_plugin_registrant.cc | 3 - windows/flutter/generated_plugins.cmake | 1 - 18 files changed, 370 insertions(+), 420 deletions(-) create mode 100644 lib/components/base/loading.dart delete mode 100644 lib/components/loading/loading.dart diff --git a/lib/components/base/loading.dart b/lib/components/base/loading.dart new file mode 100644 index 0000000..b2bed8f --- /dev/null +++ b/lib/components/base/loading.dart @@ -0,0 +1,61 @@ +import 'dart:math'; + +import 'package:flutter/material.dart'; + +class MoodiaryLoading extends StatelessWidget { + const MoodiaryLoading({super.key, this.size = 24, this.color}); + + final double size; + final Color? color; + + @override + Widget build(BuildContext context) { + return Center(child: CircularProgressIndicator(color: color)); + } +} + +class MoodiarySyncing extends StatefulWidget { + const MoodiarySyncing({super.key}); + + @override + State createState() => _MoodiarySyncingState(); +} + +class _MoodiarySyncingState extends State + with SingleTickerProviderStateMixin { + late AnimationController _controller; + late Animation _animation; + + @override + void initState() { + super.initState(); + _controller = AnimationController( + vsync: this, + duration: const Duration(seconds: 2), + )..repeat(); + + _animation = CurvedAnimation( + parent: _controller, + curve: Curves.elasticInOut, + ); + } + + @override + Widget build(BuildContext context) { + return Center( + child: AnimatedBuilder( + animation: _animation, + builder: (context, child) { + return Transform.rotate(angle: _animation.value * 2 * pi, child: child); + }, + child: const Icon(Icons.sync_rounded), + ), + ); + } + + @override + void dispose() { + _controller.dispose(); + super.dispose(); + } +} diff --git a/lib/components/category_choice_sheet/category_choice_sheet_view.dart b/lib/components/category_choice_sheet/category_choice_sheet_view.dart index 278f1d0..7149fe4 100644 --- a/lib/components/category_choice_sheet/category_choice_sheet_view.dart +++ b/lib/components/category_choice_sheet/category_choice_sheet_view.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/main.dart'; import 'package:refreshed/refreshed.dart'; @@ -27,65 +27,67 @@ class CategoryChoiceSheetComponent extends StatelessWidget { child: Obx(() { return AnimatedSwitcher( duration: const Duration(milliseconds: 300), - child: !state.isFetching.value - ? Wrap( - spacing: 4.0, - runSpacing: 4.0, - alignment: WrapAlignment.start, - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - Text( - l10n.categoryAllCategory, - style: textStyle.titleMedium, - ), - Text( - state.categoryList.length.toString(), - style: textStyle.titleMedium, - ) - ], - ), - ActionChip( - label: Text(l10n.categoryAll), - onPressed: () { - logic.selectCategory(categoryId: null); - }, - materialTapTargetSize: - MaterialTapTargetSize.shrinkWrap, - padding: EdgeInsets.zero, - backgroundColor: colorScheme.tertiaryContainer, - ), - ...List.generate(state.categoryList.value.length, - (index) { - return ActionChip( - label: Text( - state.categoryList.value[index].categoryName), + child: + !state.isFetching.value + ? Wrap( + spacing: 4.0, + runSpacing: 4.0, + alignment: WrapAlignment.start, + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + Text( + l10n.categoryAllCategory, + style: textStyle.titleMedium, + ), + Text( + state.categoryList.length.toString(), + style: textStyle.titleMedium, + ), + ], + ), + ActionChip( + label: Text(l10n.categoryAll), onPressed: () { - logic.selectCategory( - categoryId: - state.categoryList.value[index].id); + logic.selectCategory(categoryId: null); }, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, padding: EdgeInsets.zero, - backgroundColor: colorScheme.secondaryContainer, - ); - }), - Align( - alignment: Alignment.centerRight, - child: TextButton( - onPressed: () { - logic.toCategoryManage(context); - }, - child: Text(l10n.settingFunctionCategoryManage), + backgroundColor: colorScheme.tertiaryContainer, ), - ) - ], - ) - : const Center( - child: Processing(), - ), + ...List.generate(state.categoryList.value.length, ( + index, + ) { + return ActionChip( + label: Text( + state.categoryList.value[index].categoryName, + ), + onPressed: () { + logic.selectCategory( + categoryId: + state.categoryList.value[index].id, + ); + }, + materialTapTargetSize: + MaterialTapTargetSize.shrinkWrap, + padding: EdgeInsets.zero, + backgroundColor: colorScheme.secondaryContainer, + ); + }), + Align( + alignment: Alignment.centerRight, + child: TextButton( + onPressed: () { + logic.toCategoryManage(context); + }, + child: Text(l10n.settingFunctionCategoryManage), + ), + ), + ], + ) + : const MoodiaryLoading(), ); }), ), diff --git a/lib/components/diary_tab_view/diary_tab_view_view.dart b/lib/components/diary_tab_view/diary_tab_view_view.dart index d6f6e7e..b7ccac6 100644 --- a/lib/components/diary_tab_view/diary_tab_view_view.dart +++ b/lib/components/diary_tab_view/diary_tab_view_view.dart @@ -1,9 +1,9 @@ import 'package:flutter/material.dart'; import 'package:moodiary/common/values/view_mode.dart'; import 'package:moodiary/components/base/clipper.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/diary_card/grid_diary_card_view.dart'; import 'package:moodiary/components/diary_card/list_diary_card_view.dart'; -import 'package:moodiary/components/loading/loading.dart'; import 'package:moodiary/main.dart'; import 'package:refreshed/refreshed.dart'; import 'package:sliver_tools/sliver_tools.dart'; @@ -19,13 +19,7 @@ class DiaryTabViewComponent extends StatelessWidget { Widget _buildPlaceholder(double height) { return SliverToBoxAdapter( key: const ValueKey('placeholder'), - child: SizedBox( - height: height, - child: const Align( - alignment: Alignment.bottomCenter, - child: EditingLoading(), - ), - ), + child: SizedBox(height: height, child: const MoodiaryLoading()), ); } @@ -34,10 +28,7 @@ class DiaryTabViewComponent extends StatelessWidget { key: const ValueKey('empty'), child: SizedBox( height: height, - child: Align( - alignment: Alignment.bottomCenter, - child: Text(l10n.diaryTabViewEmpty), - ), + child: Center(child: Text(l10n.diaryTabViewEmpty)), ), ); } @@ -52,7 +43,12 @@ class DiaryTabViewComponent extends StatelessWidget { ); final state = Bind.find(tag: logicTag).state; final size = MediaQuery.sizeOf(context); - final placeholderHeight = size.height / 2 - kToolbarHeight - 46; + final placeholderHeight = + size.height - + barHeight - + MediaQuery.paddingOf(context).bottom - + 56 - + 46; Widget buildGrid() { return Obx(() { diff --git a/lib/components/loading/loading.dart b/lib/components/loading/loading.dart deleted file mode 100644 index 2a9a0bb..0000000 --- a/lib/components/loading/loading.dart +++ /dev/null @@ -1,104 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:rive_animated_icon/rive_animated_icon.dart'; - -class Processing extends StatelessWidget { - final Color? color; - - const Processing({super.key, this.color}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.reload, - width: 80, - height: 80, - color: color ?? colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} - -class SearchLoading extends StatelessWidget { - const SearchLoading({super.key}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.search, - width: 80, - height: 80, - color: colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} - -class EditingLoading extends StatelessWidget { - const EditingLoading({super.key}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.edit, - width: 80, - height: 80, - color: colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} - -class NetworkLoading1 extends StatelessWidget { - const NetworkLoading1({super.key}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.wifi, - width: 80, - height: 80, - color: colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} - -class NetworkLoading2 extends StatelessWidget { - const NetworkLoading2({super.key}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.globe, - width: 80, - height: 80, - color: colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} - -class MediaLoading extends StatelessWidget { - final Color? color; - - final double? size; - - const MediaLoading({super.key, this.color, this.size}); - - @override - Widget build(BuildContext context) { - final colorScheme = Theme.of(context).colorScheme; - return LoopingRiveIcon( - riveIcon: RiveIcon.gallery, - width: size ?? 80, - height: size ?? 80, - color: color ?? colorScheme.onSurface, - strokeWidth: 4.0, - ); - } -} diff --git a/lib/components/sync_dash_board/sync_dash_board_view.dart b/lib/components/sync_dash_board/sync_dash_board_view.dart index 48de33a..f7a175d 100644 --- a/lib/components/sync_dash_board/sync_dash_board_view.dart +++ b/lib/components/sync_dash_board/sync_dash_board_view.dart @@ -1,5 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/local_send/local_send_view.dart'; import 'package:moodiary/components/sync_dash_board/sync_dash_board_state.dart'; import 'package:moodiary/components/sync_dash_board/web_dav_dashboard/web_dav_dashboard_view.dart'; @@ -21,9 +21,10 @@ class SyncDashBoardComponent extends StatelessWidget { assignId: true, builder: (_) { return AnimatedSwitcher( - duration: const Duration(milliseconds: 400), - child: !state.isFetching - ? Column( + duration: const Duration(milliseconds: 400), + child: + !state.isFetching + ? Column( mainAxisSize: MainAxisSize.min, children: [ Expanded( @@ -41,10 +42,11 @@ class SyncDashBoardComponent extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ IconButton( - onPressed: () { - logic.changePage(0); - }, - icon: const Icon(Icons.chevron_left_rounded)), + onPressed: () { + logic.changePage(0); + }, + icon: const Icon(Icons.chevron_left_rounded), + ), Expanded( child: Center( child: SmoothPageIndicator( @@ -52,24 +54,27 @@ class SyncDashBoardComponent extends StatelessWidget { count: 2, axisDirection: Axis.horizontal, effect: ExpandingDotsEffect( - dotWidth: 8.0, - dotHeight: 8.0, - activeDotColor: colorScheme.primary, - dotColor: colorScheme.secondary), + dotWidth: 8.0, + dotHeight: 8.0, + activeDotColor: colorScheme.primary, + dotColor: colorScheme.secondary, + ), ), ), ), IconButton( - onPressed: () { - logic.changePage(1); - }, - icon: const Icon(Icons.chevron_right_rounded)), + onPressed: () { + logic.changePage(1); + }, + icon: const Icon(Icons.chevron_right_rounded), + ), ], ), ), ], ) - : const Center(child: NetworkLoading1())); + : const MoodiaryLoading(), + ); }, ); } diff --git a/lib/components/sync_dash_board/web_dav_dashboard/web_dav_dashboard_view.dart b/lib/components/sync_dash_board/web_dav_dashboard/web_dav_dashboard_view.dart index 8cc57d3..1eba4f2 100644 --- a/lib/components/sync_dash_board/web_dav_dashboard/web_dav_dashboard_view.dart +++ b/lib/components/sync_dash_board/web_dav_dashboard/web_dav_dashboard_view.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:moodiary/common/values/webdav.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/tile/setting_tile.dart'; import 'package:moodiary/main.dart'; import 'package:moodiary/utils/webdav_util.dart'; @@ -198,7 +198,7 @@ class WebDavDashboardComponent extends StatelessWidget { ], ], ), - if (state.isFetching) const Center(child: Processing()), + if (state.isFetching) const MoodiaryLoading(), if (state.connectivityStatus.value == WebDavConnectivityStatus.unconnected) _buildError(), diff --git a/lib/components/video_player/video_player_view.dart b/lib/components/video_player/video_player_view.dart index 168a534..0eeee27 100644 --- a/lib/components/video_player/video_player_view.dart +++ b/lib/components/video_player/video_player_view.dart @@ -1,6 +1,6 @@ import 'package:chewie/chewie.dart'; import 'package:flutter/material.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:refreshed/refreshed.dart'; import 'video_player_logic.dart'; @@ -13,11 +13,12 @@ class VideoPlayerComponent extends StatelessWidget { @override Widget build(BuildContext context) { - final VideoPlayerLogic logic = - Get.put(VideoPlayerLogic(videoPath: videoPath), tag: videoPath); + final VideoPlayerLogic logic = Get.put( + VideoPlayerLogic(videoPath: videoPath), + tag: videoPath, + ); final VideoPlayerState state = Bind.find(tag: videoPath).state; - final colorScheme = Theme.of(context).colorScheme; // Widget buildCustomTheme({required Widget child}) { // if (Platform.isAndroid || Platform.isIOS) { @@ -54,11 +55,7 @@ class VideoPlayerComponent extends StatelessWidget { child: Obx(() { return state.isInitialized.value ? Chewie(controller: logic.chewieController) - : Center( - child: MediaLoading( - color: colorScheme.primary, - size: 56, - )); + : const MoodiaryLoading(); }), ), ); diff --git a/lib/main.dart b/lib/main.dart index 1aeafe1..4bd537c 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -39,12 +39,7 @@ Future _initSystem() async { await IsarUtil.initIsar(); await ThemeUtil().buildTheme(); await WebDavUtil().initWebDav(); - VideoPlayerMediaKit.ensureInitialized( - android: true, - iOS: true, - macOS: true, - windows: true, - ); + VideoPlayerMediaKit.ensureInitialized(windows: true); SystemChrome.setEnabledSystemUIMode(SystemUiMode.edgeToEdge); SystemChrome.setSystemUIOverlayStyle( const SystemUiOverlayStyle( diff --git a/lib/pages/category_manager/category_manager_view.dart b/lib/pages/category_manager/category_manager_view.dart index 696d6ec..50cbfc6 100644 --- a/lib/pages/category_manager/category_manager_view.dart +++ b/lib/pages/category_manager/category_manager_view.dart @@ -1,7 +1,7 @@ import 'package:adaptive_dialog/adaptive_dialog.dart'; import 'package:flutter/material.dart'; import 'package:moodiary/components/base/button.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/tile/setting_tile.dart'; import 'package:moodiary/main.dart'; import 'package:refreshed/refreshed.dart'; @@ -71,9 +71,7 @@ class CategoryManagerPage extends StatelessWidget { }, itemCount: state.categoryList.length, ) - : const Center( - child: Processing(), - ), + : const MoodiaryLoading(), ); }), floatingActionButton: Obx(() { diff --git a/lib/pages/font/font_view.dart b/lib/pages/font/font_view.dart index 783db5d..f4d47a1 100644 --- a/lib/pages/font/font_view.dart +++ b/lib/pages/font/font_view.dart @@ -3,12 +3,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:moodiary/common/values/border.dart'; import 'package:moodiary/components/base/button.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/base/text.dart'; -import 'package:moodiary/components/loading/loading.dart'; import 'package:moodiary/components/tile/setting_tile.dart'; import 'package:moodiary/main.dart'; import 'package:refreshed/refreshed.dart'; -import 'package:rive_animated_icon/rive_animated_icon.dart'; import 'font_logic.dart'; @@ -36,24 +35,18 @@ class FontPage extends StatelessWidget { decoration: BoxDecoration( borderRadius: AppBorderRadius.mediumBorderRadius, border: Border.all( - color: isSelected ? activeColor : inactiveColor, - width: isSelected ? 2 : 1), + color: isSelected ? activeColor : inactiveColor, + width: isSelected ? 2 : 1, + ), ), width: 64, height: 64, child: const Center( - child: Text('Aa', - style: TextStyle( - fontSize: 32, - fontFamily: '', - )), + child: Text('Aa', style: TextStyle(fontSize: 32, fontFamily: '')), ), ), ), - AdaptiveText( - l10n.fontStyleSystem, - style: textStyle, - ), + AdaptiveText(l10n.fontStyleSystem, style: textStyle), ], ); } @@ -83,27 +76,21 @@ class FontPage extends StatelessWidget { decoration: BoxDecoration( borderRadius: AppBorderRadius.mediumBorderRadius, border: Border.all( - color: isSelected ? activeColor : inactiveColor, - width: isSelected ? 2 : 1), + color: isSelected ? activeColor : inactiveColor, + width: isSelected ? 2 : 1, + ), ), width: 64, height: 64, child: Center( child: Text( 'Aa', - style: TextStyle( - fontSize: 32, - fontFamily: fontName, - ), + style: TextStyle(fontSize: 32, fontFamily: fontName), ), ), ), ), - AdaptiveText( - fontName, - style: textStyle, - maxWidth: 64, - ), + AdaptiveText(fontName, style: textStyle, maxWidth: 64), ], ); } @@ -123,18 +110,12 @@ class FontPage extends StatelessWidget { }, child: Container( decoration: BoxDecoration( - borderRadius: AppBorderRadius.mediumBorderRadius, color: color), + borderRadius: AppBorderRadius.mediumBorderRadius, + color: color, + ), width: 64, height: 64, - child: Center( - child: LoopingRiveIcon( - riveIcon: RiveIcon.add, - width: 32, - height: 32, - strokeWidth: 4, - color: iconColor, - ), - ), + child: const Center(child: Icon(Icons.add_circle_rounded)), ), ), const SizedBox(height: 24), @@ -203,28 +184,30 @@ class FontPage extends StatelessWidget { ), ...List.generate(state.fontList.length, (index) { return _buildFont( - isSelected: state.currentFontFamily.value == - state.fontList[index].fontFamily, - fontName: state.fontList[index].fontFamily, - activeColor: colorScheme.primary, - inactiveColor: colorScheme.surfaceContainerHighest, - textStyle: textStyle.labelSmall, - context: context, - onTap: () { - logic.changeSelectedFont(font: state.fontList[index]); - }, - onLongPress: () async { - // 显示删除字体对话框 - final res = showOkCancelAlertDialog( - context: context, - title: l10n.hint, - style: AdaptiveStyle.material, - message: l10n.fontDeleteDes(state.fontList[index].fontFamily), - ); - if (await res == OkCancelResult.ok) { - logic.deleteFont(font: state.fontList[index]); - } - }); + isSelected: + state.currentFontFamily.value == + state.fontList[index].fontFamily, + fontName: state.fontList[index].fontFamily, + activeColor: colorScheme.primary, + inactiveColor: colorScheme.surfaceContainerHighest, + textStyle: textStyle.labelSmall, + context: context, + onTap: () { + logic.changeSelectedFont(font: state.fontList[index]); + }, + onLongPress: () async { + // 显示删除字体对话框 + final res = showOkCancelAlertDialog( + context: context, + title: l10n.hint, + style: AdaptiveStyle.material, + message: l10n.fontDeleteDes(state.fontList[index].fontFamily), + ); + if (await res == OkCancelResult.ok) { + logic.deleteFont(font: state.fontList[index]); + } + }, + ); }), _buildManage( onTap: logic.addFont, @@ -239,21 +222,19 @@ class FontPage extends StatelessWidget { children: [ Padding( padding: const EdgeInsets.symmetric(horizontal: 24), - child: size.width < 600 - ? SingleChildScrollView( - scrollDirection: Axis.horizontal, - child: Obx(() { - return Row( - spacing: 16, - children: buildFontButton(), - ); - }), - ) - : Wrap( - spacing: 16, - runSpacing: 16, - children: buildFontButton(), - ), + child: + size.width < 600 + ? SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: Obx(() { + return Row(spacing: 16, children: buildFontButton()); + }), + ) + : Wrap( + spacing: 16, + runSpacing: 16, + children: buildFontButton(), + ), ), const Divider(endIndent: 24, indent: 24), AdaptiveListTile( @@ -270,7 +251,7 @@ class FontPage extends StatelessWidget { 1.1 => l10n.fontSizeLarge, 1.2 => l10n.fontSizeSuperLarge, _ => l10n.fontSizeStandard, - }) + }), ], ), ), @@ -298,47 +279,49 @@ class FontPage extends StatelessWidget { backgroundColor: colorScheme.surfaceContainerLow, ), backgroundColor: colorScheme.surfaceContainerLow, - body: size.width < 600 - ? Obx(() { - return !state.isFetching.value - ? Padding( + body: + size.width < 600 + ? Obx(() { + return !state.isFetching.value + ? Padding( padding: EdgeInsets.only( - left: 16, - right: 16, - bottom: state.bottomSheetHeight.value), + left: 16, + right: 16, + bottom: state.bottomSheetHeight.value, + ), child: buildText(), ) - : const Center( - child: Processing(), - ); - }) - : Obx(() { - return !state.isFetching.value - ? RepaintBoundary( + : const MoodiaryLoading(); + }) + : Obx(() { + return !state.isFetching.value + ? RepaintBoundary( child: Row( children: [ Expanded( - child: Padding( - padding: - const EdgeInsets.only(left: 16, right: 16), - child: buildText(), - )), - Expanded(child: buildOption()) + child: Padding( + padding: const EdgeInsets.only( + left: 16, + right: 16, + ), + child: buildText(), + ), + ), + Expanded(child: buildOption()), ], ), ) - : const Center( - child: Processing(), - ); - }), + : const MoodiaryLoading(); + }), resizeToAvoidBottomInset: false, - floatingActionButton: size.width > 600 - ? FloatingActionButton.extended( - onPressed: logic.saveFontScale, - label: Text(l10n.apply), - icon: const Icon(Icons.check_rounded), - ) - : null, + floatingActionButton: + size.width > 600 + ? FloatingActionButton.extended( + onPressed: logic.saveFontScale, + label: Text(l10n.apply), + icon: const Icon(Icons.check_rounded), + ) + : null, bottomSheet: Obx(() { return Visibility( visible: !state.isFetching.value && size.width < 600, @@ -376,9 +359,7 @@ class FontPage extends StatelessWidget { ), ), ), - Expanded( - child: buildOption(), - ), + Expanded(child: buildOption()), Padding( padding: const EdgeInsets.symmetric(horizontal: 24), child: FilledButton( diff --git a/lib/pages/home/calendar/calendar_view.dart b/lib/pages/home/calendar/calendar_view.dart index 1b59753..f13a2ed 100644 --- a/lib/pages/home/calendar/calendar_view.dart +++ b/lib/pages/home/calendar/calendar_view.dart @@ -3,8 +3,8 @@ import 'package:flutter/material.dart'; import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:moodiary/common/values/border.dart'; import 'package:moodiary/common/values/colors.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/diary_card/calendar_diary_card_view.dart'; -import 'package:moodiary/components/loading/loading.dart'; import 'package:moodiary/components/time_line/time_line_view.dart'; import 'package:moodiary/utils/array_util.dart'; import 'package:refreshed/refreshed.dart'; @@ -219,10 +219,7 @@ class CalendarPage extends StatelessWidget { duration: const Duration(milliseconds: 300), child: state.isFetching.value - ? const Center( - key: ValueKey('processing'), - child: Processing(), - ) + ? const MoodiaryLoading() : (state.currentMonthDiaryList.isNotEmpty ? buildCardList() : Center( diff --git a/lib/pages/home/diary/diary_view.dart b/lib/pages/home/diary/diary_view.dart index 3e0fb13..b1b8fd6 100644 --- a/lib/pages/home/diary/diary_view.dart +++ b/lib/pages/home/diary/diary_view.dart @@ -1,6 +1,7 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; import 'package:moodiary/common/values/view_mode.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/base/sheet.dart'; import 'package:moodiary/components/base/text.dart'; import 'package:moodiary/components/category_choice_sheet/category_choice_sheet_view.dart'; @@ -12,7 +13,6 @@ import 'package:moodiary/components/sync_dash_board/sync_dash_board_view.dart'; import 'package:moodiary/main.dart'; import 'package:moodiary/utils/webdav_util.dart'; import 'package:refreshed/refreshed.dart'; -import 'package:rive_animated_icon/rive_animated_icon.dart'; import 'diary_logic.dart'; @@ -31,14 +31,7 @@ class DiaryPage extends StatelessWidget { color: colorScheme.primaryContainer, shape: BoxShape.circle, ), - child: RiveAnimatedIcon( - riveIcon: RiveIcon.reload, - color: colorScheme.onPrimaryContainer, - width: 24, - height: 24, - loopAnimation: true, - onTap: onTap, - ), + child: const MoodiarySyncing(), ), ); } diff --git a/lib/pages/home/media/media_view.dart b/lib/pages/home/media/media_view.dart index b39ff25..115916e 100644 --- a/lib/pages/home/media/media_view.dart +++ b/lib/pages/home/media/media_view.dart @@ -4,7 +4,7 @@ import 'package:font_awesome_flutter/font_awesome_flutter.dart'; import 'package:moodiary/common/values/border.dart'; import 'package:moodiary/common/values/media_type.dart'; import 'package:moodiary/components/base/clipper.dart'; -import 'package:moodiary/components/loading/loading.dart'; +import 'package:moodiary/components/base/loading.dart'; import 'package:moodiary/components/lottie_modal/lottie_modal.dart'; import 'package:moodiary/components/media/media_audio_view.dart'; import 'package:moodiary/components/media/media_image_view.dart'; @@ -120,10 +120,7 @@ class MediaPage extends StatelessWidget { duration: const Duration(milliseconds: 400), child: state.isFetching - ? const Center( - key: ValueKey('searching'), - child: SearchLoading(), - ) + ? const MoodiaryLoading() : (state.datetimeMediaMap.isNotEmpty ? PageClipper( child: ScrollablePositionedList.builder( diff --git a/lib/presentation/isar.dart b/lib/presentation/isar.dart index f7c81be..6d6ba61 100644 --- a/lib/presentation/isar.dart +++ b/lib/presentation/isar.dart @@ -23,11 +23,7 @@ import 'package:uuid/uuid.dart'; class IsarUtil { static late final Isar _isar; - static final _schemas = [ - DiarySchema, - CategorySchema, - FontSchema, - ]; + static final _schemas = [DiarySchema, CategorySchema, FontSchema]; static Future initIsar() async { _isar = await Isar.openAsync( @@ -70,11 +66,11 @@ class IsarUtil { //导出数据 static Future exportIsar( - String dir, String path, String fileName) async { - final isar = Isar.open( - schemas: _schemas, - directory: join(dir, 'database'), - ); + String dir, + String path, + String fileName, + ) async { + final isar = Isar.open(schemas: _schemas, directory: join(dir, 'database')); isar.copyToFile(join(path, fileName)); isar.close(); } @@ -102,8 +98,11 @@ class IsarUtil { } //根据日期范围获取日记 - static Future> getDiariesByDateRange(DateTime start, DateTime end, - {bool all = true}) async { + static Future> getDiariesByDateRange( + DateTime start, + DateTime end, { + bool all = true, + }) async { return await _isar.diarys .where() .timeBetween(start, end) @@ -127,7 +126,9 @@ class IsarUtil { //获取指定范围内的天气 static Future>> getWeatherByDateRange( - DateTime start, DateTime end) async { + DateTime start, + DateTime end, + ) async { return (await _isar.diarys .where() .showEqualTo(true) @@ -140,7 +141,9 @@ class IsarUtil { //获取指定范围的心情指数 static Future> getMoodByDateRange( - DateTime start, DateTime end) async { + DateTime start, + DateTime end, + ) async { return (await _isar.diarys .where() .showEqualTo(true) @@ -168,8 +171,10 @@ class IsarUtil { } //更新日记 - static Future updateADiary( - {Diary? oldDiary, required Diary newDiary}) async { + static Future updateADiary({ + Diary? oldDiary, + required Diary newDiary, + }) async { // 如果没有旧日记,说明是新增日记 newDiary.lastModified = DateTime.now(); await _isar.writeAsync((isar) { @@ -181,8 +186,12 @@ class IsarUtil { await FileUtil.cleanUpOldMediaFiles(oldDiary, newDiary); if (WebDavUtil().hasOption && PrefUtil.getValue('autoSyncAfterChange') == true) { - unawaited(WebDavUtil() - .updateSingleDiary(oldDiary: oldDiary, newDiary: newDiary)); + unawaited( + WebDavUtil().updateSingleDiary( + oldDiary: oldDiary, + newDiary: newDiary, + ), + ); } } else { if (WebDavUtil().hasOption && @@ -194,16 +203,18 @@ class IsarUtil { //查询日记 static Future> searchDiaries(String value) async { - final contentResults = await _isar.diarys - .where() - .showEqualTo(true) - .contentTextContains(value) - .findAllAsync(); - final titleResults = await _isar.diarys - .where() - .showEqualTo(true) - .titleContains(value) - .findAllAsync(); + final contentResults = + await _isar.diarys + .where() + .showEqualTo(true) + .contentTextContains(value) + .findAllAsync(); + final titleResults = + await _isar.diarys + .where() + .showEqualTo(true) + .titleContains(value) + .findAllAsync(); // 合并并去重 final combinedResults = {...contentResults, ...titleResults}.toList(); @@ -245,10 +256,11 @@ class IsarUtil { static Future insertACategory(Category category) async { return await _isar.writeAsync((isar) { // 查询数据库中是否有同名但 ID 不同的分类 - final existingCategory = isar.categorys - .where() - .categoryNameEqualTo(category.categoryName) - .findFirst(); + final existingCategory = + isar.categorys + .where() + .categoryNameEqualTo(category.categoryName) + .findFirst(); if (existingCategory != null && existingCategory.id != category.id) { // 如果同名但 ID 不同,则修改分类名称并添加随机后缀 category.categoryName = @@ -267,10 +279,11 @@ class IsarUtil { static Future updateACategory(Category category) async { return await _isar.writeAsync((isar) { // 查询数据库中是否有同名但 ID 不同的分类 - final existingCategory = isar.categorys - .where() - .categoryNameEqualTo(category.categoryName) - .findFirst(); + final existingCategory = + isar.categorys + .where() + .categoryNameEqualTo(category.categoryName) + .findFirst(); if (existingCategory != null && existingCategory.id != category.id) { // 如果同名但 ID 不同,则修改分类名称并添加随机后缀 category.categoryName = @@ -314,7 +327,10 @@ class IsarUtil { //获取对应分类的日记,如果为空,返回全部日记 static Future> getDiaryByCategory( - String? categoryId, int offset, int limit) async { + String? categoryId, + int offset, + int limit, + ) async { if (categoryId == null) { return await _isar.diarys .where() @@ -337,25 +353,24 @@ class IsarUtil { .where() .showEqualTo(true) .yMdEqualTo( - '${time.year.toString()}/${time.month.toString()}/${time.day.toString()}') + '${time.year.toString()}/${time.month.toString()}/${time.day.toString()}', + ) .sortByTimeDesc() .findAllAsync(); } static Future> getDiary(int offset, int limit) async { - return await _isar.diarys - .where() - .findAllAsync(offset: offset, limit: limit); + return await _isar.diarys.where().findAllAsync( + offset: offset, + limit: limit, + ); } /// 2.4.8 版本变更 /// 新增字段 /// 1.position 用于记录位置 static void mergeToV2_4_8(String dir) { - final isar = Isar.open( - schemas: _schemas, - directory: dir, - ); + final isar = Isar.open(schemas: _schemas, directory: dir); final countDiary = isar.diarys.where().count(); for (var i = 0; i < countDiary; i += 50) { final diaries = isar.diarys.where().findAll(offset: i, limit: 50); @@ -374,10 +389,7 @@ class IsarUtil { /// 1.将时间字段修改为最后修改时间 /// 2.将类型字段修改为富文本 static void mergeToV2_6_0(String dir) { - final isar = Isar.open( - schemas: _schemas, - directory: dir, - ); + final isar = Isar.open(schemas: _schemas, directory: dir); final countDiary = isar.diarys.where().count(); for (var i = 0; i < countDiary; i += 50) { @@ -392,8 +404,9 @@ class IsarUtil { diary.type = DiaryType.richText.value; diary.lastModified = diary.time; // 设置最后修改时间 // 遍历资源文件,将资源文件插入到富文本中 - quillController.document = - Document.fromJson(jsonDecode(diary.content)); + quillController.document = Document.fromJson( + jsonDecode(diary.content), + ); for (final image in diary.imageName) { insertNewImage(imageName: image, quillController: quillController); @@ -406,8 +419,9 @@ class IsarUtil { } // 更新富文本内容 - diary.content = - jsonEncode(quillController.document.toDelta().toJson()); + diary.content = jsonEncode( + quillController.document.toDelta().toJson(), + ); // 保存更新后的日记 isar.diarys.put(diary); @@ -425,10 +439,7 @@ class IsarUtil { /// 修复之前webdav同步时,没有同步分类的问题 /// 遍历所有日记,如果本地没有日记的分类,就创建一个分类,名称为分类名 static void fixV2_6_3(String dir) { - final isar = Isar.open( - schemas: _schemas, - directory: dir, - ); + final isar = Isar.open(schemas: _schemas, directory: dir); final countDiary = isar.diarys.where().count(); for (var i = 0; i < countDiary; i += 50) { final diaries = isar.diarys.where().findAll(offset: i, limit: 50); @@ -449,31 +460,49 @@ class IsarUtil { isar.close(); } - static void insertNewImage( - {required String imageName, required QuillController quillController}) { + static void insertNewImage({ + required String imageName, + required QuillController quillController, + }) { final imageBlock = ImageBlockEmbed.fromName(imageName); final index = quillController.selection.baseOffset; final length = quillController.selection.extentOffset - index; quillController.replaceText( - index, length, imageBlock, TextSelection.collapsed(offset: index + 1)); + index, + length, + imageBlock, + TextSelection.collapsed(offset: index + 1), + ); } - static void insertNewVideo( - {required String videoName, required QuillController quillController}) { + static void insertNewVideo({ + required String videoName, + required QuillController quillController, + }) { final videoBlock = VideoBlockEmbed.fromName(videoName); final index = quillController.selection.baseOffset; final length = quillController.selection.extentOffset - index; quillController.replaceText( - index, length, videoBlock, TextSelection.collapsed(offset: index + 1)); + index, + length, + videoBlock, + TextSelection.collapsed(offset: index + 1), + ); } - static void insertAudio( - {required String audioName, required QuillController quillController}) { + static void insertAudio({ + required String audioName, + required QuillController quillController, + }) { final audioBlock = AudioBlockEmbed.fromName(audioName); final index = quillController.selection.baseOffset; final length = quillController.selection.extentOffset - index; quillController.replaceText( - index, length, audioBlock, TextSelection.collapsed(offset: index + 1)); + index, + length, + audioBlock, + TextSelection.collapsed(offset: index + 1), + ); } // 获取用于地图显示的对象 @@ -484,17 +513,23 @@ class IsarUtil { /// 要满足以下条件 /// 1. 有定位坐标 /// 2. show - final diaries = await _isar.diarys - .where() - .showEqualTo(true) - .positionIsNotEmpty() - .findAllAsync(); + final diaries = + await _isar.diarys + .where() + .showEqualTo(true) + .positionIsNotEmpty() + .findAllAsync(); for (final diary in diaries) { - res.add(DiaryMapItem( + res.add( + DiaryMapItem( LatLng( - double.parse(diary.position[0]), double.parse(diary.position[1])), + double.parse(diary.position[0]), + double.parse(diary.position[1]), + ), diary.isarId, - diary.imageName.isEmpty ? '' : diary.imageName.first)); + diary.imageName.isEmpty ? '' : diary.imageName.first, + ), + ); } return res; } @@ -523,10 +558,7 @@ class IsarUtil { } static Future mergeToV2_7_3(Map parma) async { - final isar = Isar.open( - schemas: _schemas, - directory: parma['database']!, - ); + final isar = Isar.open(schemas: _schemas, directory: parma['database']!); await isar.writeAsync((isar) { isar.fonts.clear(); diff --git a/lib/utils/theme_util.dart b/lib/utils/theme_util.dart index c5a877c..8c0f784 100644 --- a/lib/utils/theme_util.dart +++ b/lib/utils/theme_util.dart @@ -310,6 +310,14 @@ class ThemeUtil { thickness: WidgetStateProperty.all(4.0), radius: const Radius.circular(2.0), ), + progressIndicatorTheme: const ProgressIndicatorThemeData( + // ignore: deprecated_member_use + year2023: false, + ), + sliderTheme: const SliderThemeData( + // ignore: deprecated_member_use + year2023: false, + ), brightness: brightness, appBarTheme: AppBarTheme( surfaceTintColor: Colors.transparent, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 156b867..120997d 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -24,14 +24,12 @@ import isar_flutter_libs import local_auth_darwin import macos_ui import macos_window_utils -import media_kit_libs_macos_video import media_kit_video import network_info_plus import package_info_plus import path_provider_foundation import quill_native_bridge_macos import record_darwin -import rive_common import screen_brightness_macos import share_plus import shared_preferences_foundation @@ -60,14 +58,12 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { FLALocalAuthPlugin.register(with: registry.registrar(forPlugin: "FLALocalAuthPlugin")) MacOSUiPlugin.register(with: registry.registrar(forPlugin: "MacOSUiPlugin")) MacOSWindowUtilsPlugin.register(with: registry.registrar(forPlugin: "MacOSWindowUtilsPlugin")) - MediaKitLibsMacosVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitLibsMacosVideoPlugin")) MediaKitVideoPlugin.register(with: registry.registrar(forPlugin: "MediaKitVideoPlugin")) NetworkInfoPlusPlugin.register(with: registry.registrar(forPlugin: "NetworkInfoPlusPlugin")) FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) QuillNativeBridgePlugin.register(with: registry.registrar(forPlugin: "QuillNativeBridgePlugin")) RecordPlugin.register(with: registry.registrar(forPlugin: "RecordPlugin")) - RivePlugin.register(with: registry.registrar(forPlugin: "RivePlugin")) ScreenBrightnessMacosPlugin.register(with: registry.registrar(forPlugin: "ScreenBrightnessMacosPlugin")) SharePlusMacosPlugin.register(with: registry.registrar(forPlugin: "SharePlusMacosPlugin")) SharedPreferencesPlugin.register(with: registry.registrar(forPlugin: "SharedPreferencesPlugin")) diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 3ecd52f..d163103 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -63,8 +62,6 @@ void RegisterPlugins(flutter::PluginRegistry* registry) { registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); RecordWindowsPluginCApiRegisterWithRegistrar( registry->GetRegistrarForPlugin("RecordWindowsPluginCApi")); - RivePluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("RivePlugin")); ScreenBrightnessWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("ScreenBrightnessWindowsPlugin")); SharePlusWindowsPluginCApiRegisterWithRegistrar( diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 566ff02..44dbdb3 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -20,7 +20,6 @@ list(APPEND FLUTTER_PLUGIN_LIST media_kit_video permission_handler_windows record_windows - rive_common screen_brightness_windows share_plus url_launcher_windows