From acef024e0a5ea41da7f4ae75bbabfef81dbf3424 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E6=BB=8B=E6=B6=A6?= <807046079@qq.com> Date: Fri, 4 Oct 2024 23:22:04 +0800 Subject: [PATCH] Multi-screen adaptation --- lib/api/api_server.dart | 2 +- lib/common/constant.dart | 71 ++++--- lib/common/global.dart | 1 + lib/main.dart | 148 ++++++++------ lib/model/user/model.dart | 2 + lib/model/user/user.dart | 4 +- lib/util/enter.dart | 1 + lib/util/toast.dart | 2 +- lib/view/account/detail/account_detail.dart | 46 +---- lib/view/account/edit/account_edit.dart | 23 ++- lib/view/account/list/account_list.dart | 6 +- .../list/account_list_bottom_sheet.dart | 6 +- lib/view/account/list/enter.dart | 9 +- lib/view/account/list/widget/share_label.dart | 2 +- .../mapping/account_mapping_bottom_sheet.dart | 2 +- .../account_operation_bottom_sheet.dart | 4 +- .../template/list/account_template_list.dart | 18 +- .../config/account_user_config_dialog.dart | 4 +- .../account_user_detail_buttom_sheet.dart | 19 +- .../user/detail/widget/trans_list.dart | 3 +- .../account/user/edit/user_detail_edit.dart | 14 +- .../invite/account_user_invite_dialog.dart | 15 +- lib/view/home/home.dart | 193 +++++++++--------- .../home/widget/category_amount_rank.dart | 7 +- lib/view/home/widget/enter.dart | 9 +- lib/view/home/widget/header_card.dart | 40 ++-- lib/view/home/widget/home_navigation.dart | 46 ++--- .../home/widget/statistics_line_chart.dart | 4 +- .../home/widget/time_period_statistics.dart | 10 +- lib/view/navigation/navigation.dart | 10 +- lib/view/navigation/widget/user_drawer.dart | 13 +- .../navigation/widget/user_drawer_header.dart | 17 +- lib/view/share/home/share_home.dart | 39 ++-- lib/view/share/home/widget/account_menu.dart | 8 +- lib/view/share/home/widget/account_total.dart | 12 +- .../share/home/widget/account_user_card.dart | 5 +- lib/view/share/home/widget/enter.dart | 11 +- .../share/home/widget/no_account_page.dart | 4 +- .../edit/transaction_category_edit.dart | 15 +- .../category/mapping/weiget/enter.dart | 1 + .../category/mapping/weiget/header_card.dart | 2 +- .../mapping/weiget/option_bottom_sheet.dart | 4 +- .../category/mapping/weiget/tab_view.dart | 18 +- .../transaction_category_template.dart | 4 +- .../tree/transaction_category_tree.dart | 1 + .../tree/widget/drag_and_drop_lists.dart | 12 +- .../transaction/chart/transaction_chart.dart | 5 +- .../chart/widget/category_amount_rank.dart | 4 +- .../chart/widget/category_pie_chart.dart | 18 +- lib/view/transaction/chart/widget/enter.dart | 1 + .../chart/widget/statistics_line_chart.dart | 6 +- .../chart/widget/total_header.dart | 6 +- .../transaction_detail_bottom_sheet.dart | 18 +- lib/view/transaction/edit/widget/bottom.dart | 16 +- .../edit/widget/category_picker.dart | 4 +- .../transaction/flow/transaction_flow.dart | 20 +- .../flow/widget/condition_bottom_sheet.dart | 41 ++-- lib/view/transaction/flow/widget/enter.dart | 1 + .../transaction/flow/widget/header_card.dart | 38 ++-- .../month_statistic_header_delegate.dart | 23 +-- .../import/transaction_import.dart | 6 +- .../transaction/import/widget/exec_card.dart | 4 +- .../import/widget/fail_dialog.dart | 8 +- .../transaction/import/widget/ptc_card.dart | 6 +- .../share/transaction_share_bottom_sheet.dart | 21 +- .../cubit/transaction_timing_cubit.dart | 28 +-- .../timing/list/transaction_timing_list.dart | 42 +++- .../timing/transaction_timing.dart | 8 +- .../timing/widget/bottom_select.dart | 6 +- lib/view/transaction/timing/widget/enter.dart | 1 + .../invitation/user_acount_invitation.dart | 8 +- .../share/user_config_transaction_share.dart | 4 +- .../forgetPassword/user_forgetPassword.dart | 11 +- lib/view/user/login/user_login.dart | 21 +- .../password/update/user_password_update.dart | 9 +- lib/view/user/register/user_register.dart | 15 +- lib/view/user/search/user_search.dart | 2 +- lib/widget/amount/amount_input.dart | 16 +- lib/widget/amount/amount_keyboard.dart | 17 +- lib/widget/amount/enter.dart | 1 + .../unequal_height_amount_text_span.dart | 5 +- .../category/category_icon_and_name.dart | 14 +- lib/widget/category/enter.dart | 1 + lib/widget/common/common.dart | 1 + lib/widget/common/common_captcha.dart | 8 +- lib/widget/common/common_card.dart | 8 +- lib/widget/common/common_email_captcha.dart | 21 +- lib/widget/common/common_expansion_list.dart | 4 +- lib/widget/common/common_lable.dart | 6 +- lib/widget/common/common_list_tile.dart | 10 +- lib/widget/common/common_shimmer.dart | 91 +-------- lib/widget/common/common_toast.dart | 12 +- lib/widget/common/page/common_page.dart | 6 +- lib/widget/common/page/enter.dart | 1 + lib/widget/common/page/refresh_animation.dart | 8 +- lib/widget/date/enter.dart | 1 + .../date/month_or_date_range_picker.dart | 28 +-- lib/widget/form/form.dart | 6 +- lib/widget/form/form_button.dart | 6 +- lib/widget/form/form_input_field.dart | 11 +- lib/widget/form/form_select_field.dart | 4 +- lib/widget/form/form_selecter.dart | 8 +- lib/widget/icon/circular_icon.dart | 10 +- lib/widget/icon/enter.dart | 1 + lib/widget/toast.dart | 7 +- lib/widget/transaction/enter.dart | 1 + .../transaction/transaction_container.dart | 26 ++- pubspec.yaml | 3 +- 108 files changed, 787 insertions(+), 843 deletions(-) diff --git a/lib/api/api_server.dart b/lib/api/api_server.dart index 7a71e5bb..b50707d0 100644 --- a/lib/api/api_server.dart +++ b/lib/api/api_server.dart @@ -1,4 +1,3 @@ -import 'dart:async'; import 'dart:collection'; import 'dart:core'; import 'dart:io'; @@ -129,6 +128,7 @@ class ApiServer { return ResponseBody({'Msg': '请重新登录'}, isSuccess: false); } else { logining = true; + print("ok"); return await Global.navigatorKey.currentState!.pushNamed(UserRoutes.login).then((value) { logining = false; if (isShowOverlayLoader) { diff --git a/lib/common/constant.dart b/lib/common/constant.dart index 584b6ae4..6cb13e60 100644 --- a/lib/common/constant.dart +++ b/lib/common/constant.dart @@ -1,25 +1,35 @@ part of 'global.dart'; class Constant { - static const double radius = 12.0; - static const double buttomSheetRadius = 28.0; - static const double smallPadding = 8.0; - static const double padding = 16.0; - static const double largePadding = 24.0; - static const double margin = 8.0; + static double radius = 12.0; + static double buttomSheetRadius = 28.0; + static double smallPadding = 8.0; + static double padding = 16.0; + static double largePadding = 24.0; + static double margin = 8.0; - static const double buttomHight = 320; - static const double buttomLetterSpacing = 4.0; + static double buttomHight = 320; + static double buttomLetterSpacing = 4.0; - static const double iconSize = 24; - static const double iconlargeSize = 32; - static const int maxAmount = 99999999; //最大金额为100万减一 存储单位为分 - static const int minYear = 2000; - static const int maxYear = 2050; + static double iconSize = 24; + static double iconlargeSize = 32; + static int maxAmount = 99999999; //最大金额为100万减一 存储单位为分 + static int minYear = 2000; + static int maxYear = 2050; static DateTime minDateTime = DateTime(minYear); static DateTime maxDateTime = DateTime(maxYear); static String defultLocation = 'Asia/Shanghai'; + static init() { + radius = 12.0.sp; + buttomSheetRadius = 28.0.sp; + smallPadding = 8.0.sp; + padding = 16.0.sp; + largePadding = 24.0.sp; + margin = 8.0.sp; + buttomHight = 320.0.h; + buttomLetterSpacing = 4.0.sp; + } } class ConstantFontSize { @@ -32,43 +42,50 @@ class ConstantFontSize { static const double bodySmall = 12; static const double letterSpacing = 2; + // static init() { + // largeHeadline = largeHeadline.sp; + // headline = headline.sp; + // bodyLarge = bodyLarge.sp; + // body = body.sp; + // bodySmall = bodySmall.sp; + // letterSpacing = letterSpacing.sp; + // } } class ConstantWidget { // ignore: library_private_types_in_public_api - static const _ConstantWidgetDivider divider = _ConstantWidgetDivider(); + static _ConstantWidgetDivider divider = _ConstantWidgetDivider(); static const Widget activityIndicator = CircularProgressIndicator(); } class ConstantDecoration { - static const Radius radius = Radius.circular(Constant.radius); - static const BorderRadius borderRadius = BorderRadius.all(Radius.circular(Constant.radius)); - static const BorderRadius bottomSheetBorderRadius = - BorderRadius.vertical(top: Radius.circular(Constant.buttomSheetRadius)); + static Radius radius = Radius.circular(Constant.radius); + static BorderRadius borderRadius = BorderRadius.all(Radius.circular(Constant.radius)); + static BorderRadius bottomSheetBorderRadius = BorderRadius.vertical(top: Radius.circular(Constant.buttomSheetRadius)); //BoxDecoration - static const BoxDecoration cardDecoration = BoxDecoration( + static BoxDecoration cardDecoration = BoxDecoration( color: Colors.white, borderRadius: ConstantDecoration.borderRadius, ); - static const BoxDecoration bottomSheet = BoxDecoration( + static BoxDecoration bottomSheet = BoxDecoration( color: Colors.white, borderRadius: bottomSheetBorderRadius, ); } class _ConstantWidgetDivider { - const _ConstantWidgetDivider(); - final Divider list = const Divider( + _ConstantWidgetDivider(); + final Divider list = Divider( color: ConstantColor.listDividerColor, - height: 0.5, - thickness: 0.5, + height: 0.5.sp, + thickness: 0.5.sp, ); - final Divider indented = const Divider( + final Divider indented = Divider( color: ConstantColor.listDividerColor, indent: Constant.margin, endIndent: Constant.margin, - height: 0.5, - thickness: 0.5, + height: 0.5.sp, + thickness: 0.5.sp, ); } diff --git a/lib/common/global.dart b/lib/common/global.dart index 845f3ac9..da8fc467 100644 --- a/lib/common/global.dart +++ b/lib/common/global.dart @@ -9,6 +9,7 @@ import 'package:leap_ledger_app/model/account/model.dart'; import 'package:leap_ledger_app/routes/routes.dart'; import 'package:leap_ledger_app/util/enter.dart'; import 'package:path_provider/path_provider.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; part 'constant.dart'; part 'no_data.dart'; diff --git a/lib/main.dart b/lib/main.dart index bb8028fe..9d7c1a20 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; -import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/bloc/account/account_bloc.dart'; import 'package:leap_ledger_app/bloc/category/category_bloc.dart'; @@ -14,15 +13,21 @@ import 'package:leap_ledger_app/view/navigation/navigation.dart'; import 'common/global.dart'; import 'package:leap_ledger_app/common/current.dart'; import 'package:timezone/data/latest_all.dart' as tzData; +import 'package:flutter_screenutil/flutter_screenutil.dart'; Future main() async { - WidgetsFlutterBinding.ensureInitialized(); init().then((e) => runApp(MyApp())); } Future init() async { + WidgetsFlutterBinding.ensureInitialized(); + //ScreenUtil + await ScreenUtil.ensureScreenSize(); + //TimeZones tzData.initializeTimeZones(); + //SharedPreferencesCache await SharedPreferencesCache.init(); + //config await Global.init(); await Current.init(); //await Global.cache.clear(); @@ -39,6 +44,8 @@ class MyApp extends StatelessWidget { final AccountBloc _accountBloc = AccountBloc(); @override Widget build(BuildContext context) { + ScreenUtil.init(context); + return MultiRepositoryProvider( providers: [ RepositoryProvider(create: (context) => UserBloc(_accountBloc)), @@ -47,73 +54,80 @@ class MyApp extends StatelessWidget { RepositoryProvider(create: (context) => TransactionBloc()), RepositoryProvider(create: (context) => CategoryBloc()), ], - child: MaterialApp( - supportedLocales: const [ - Locale('zh', 'CN'), - ], - localizationsDelegates: const [ - GlobalMaterialLocalizations.delegate, - GlobalWidgetsLocalizations.delegate, - GlobalCupertinoLocalizations.delegate, - ], - localeResolutionCallback: (locale, supportedLocales) { - for (var supportedLocale in supportedLocales) { - if (supportedLocale.languageCode == locale?.languageCode && - supportedLocale.countryCode == locale?.countryCode) { - Intl.defaultLocale = supportedLocale.languageCode; - return supportedLocale; - } - } - Intl.defaultLocale = supportedLocales.first.languageCode; - return supportedLocales.first; - }, - navigatorKey: Global.navigatorKey, - title: 'Flutter Demo', - theme: ThemeData( - tabBarTheme: const TabBarTheme( - dividerHeight: 0, - overlayColor: WidgetStatePropertyAll( - Colors.white, - ), - ), - colorScheme: const ColorScheme.light( - primary: ConstantColor.primaryColor, - secondary: ConstantColor.secondaryColor, - ), - primaryColor: ConstantColor.primaryColor, - dividerColor: Colors.transparent, - appBarTheme: AppBarTheme( - color: Colors.white, - shadowColor: ConstantColor.shadowColor, - surfaceTintColor: Colors.white, - ), - elevatedButtonTheme: ElevatedButtonThemeData( - style: ButtonStyle( - backgroundColor: WidgetStatePropertyAll(Colors.blue), - foregroundColor: WidgetStatePropertyAll(Colors.white), + child: ScreenUtilInit( + designSize: const Size(375, 667), + minTextAdapt: true, + splitScreenMode: true, + builder: (context, child) { + return MaterialApp( + debugShowCheckedModeBanner: false, + supportedLocales: const [ + Locale('zh', 'CN'), + ], + localizationsDelegates: const [ + GlobalMaterialLocalizations.delegate, + GlobalWidgetsLocalizations.delegate, + GlobalCupertinoLocalizations.delegate, + ], + localeResolutionCallback: (locale, supportedLocales) { + for (var supportedLocale in supportedLocales) { + if (supportedLocale.languageCode == locale?.languageCode && + supportedLocale.countryCode == locale?.countryCode) { + Intl.defaultLocale = supportedLocale.languageCode; + return supportedLocale; + } + } + Intl.defaultLocale = supportedLocales.first.languageCode; + return supportedLocales.first; + }, + navigatorKey: Global.navigatorKey, + theme: ThemeData( + tabBarTheme: TabBarTheme( + dividerHeight: 0, + overlayColor: WidgetStatePropertyAll(Colors.white), + ), + colorScheme: const ColorScheme.light( + primary: ConstantColor.primaryColor, + secondary: ConstantColor.secondaryColor, + ), + primaryColor: ConstantColor.primaryColor, + dividerColor: Colors.transparent, + appBarTheme: AppBarTheme( + color: Colors.white, + shadowColor: ConstantColor.shadowColor, + surfaceTintColor: Colors.white, + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ButtonStyle( + backgroundColor: WidgetStatePropertyAll(Colors.blue), + foregroundColor: WidgetStatePropertyAll(Colors.white), + ), + ), + floatingActionButtonTheme: const FloatingActionButtonThemeData( + backgroundColor: Colors.blue, + shape: CircleBorder(), + // smallSizeConstraints: BoxConstraints(minWidth: 100), + // extendedSizeConstraints: BoxConstraints(minWidth: 100), + ), + bottomSheetTheme: const BottomSheetThemeData( + backgroundColor: Colors.white, + surfaceTintColor: Colors.white, + ), + iconTheme: IconThemeData.fallback().copyWith(applyTextScaling: true), + useMaterial3: true, ), - ), - floatingActionButtonTheme: const FloatingActionButtonThemeData( - backgroundColor: Colors.blue, - shape: CircleBorder(), - // smallSizeConstraints: BoxConstraints(minWidth: 100), - // extendedSizeConstraints: BoxConstraints(minWidth: 100), - ), - bottomSheetTheme: const BottomSheetThemeData( - backgroundColor: Colors.white, - surfaceTintColor: Colors.white, - ), - useMaterial3: true, - ), - home: Navigation(), - builder: EasyLoading.init(builder: (context, child) { - return MediaQuery( - data: MediaQuery.of(context).copyWith(textScaler: TextScaler.noScaling), - child: child!, + home: Navigation(), + builder: (context, widget) { + Constant.init(); + return MediaQuery( + data: MediaQuery.of(context).copyWith(textScaler: TextScaler.linear(1.sp)), + child: widget!, + ); + }, + routes: Routes.routes, + onGenerateRoute: Routes.generateRoute, ); - }), - routes: Routes.routes, - onGenerateRoute: Routes.generateRoute, + }, )); } } diff --git a/lib/model/user/model.dart b/lib/model/user/model.dart index 5c38b314..d91256f6 100644 --- a/lib/model/user/model.dart +++ b/lib/model/user/model.dart @@ -1,5 +1,7 @@ import 'package:flutter/widgets.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:json_annotation/json_annotation.dart'; +import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; import 'package:leap_ledger_app/util/enter.dart'; import 'package:leap_ledger_app/widget/common/common.dart'; diff --git a/lib/model/user/user.dart b/lib/model/user/user.dart index 627e23d4..aa4133e7 100644 --- a/lib/model/user/user.dart +++ b/lib/model/user/user.dart @@ -78,8 +78,8 @@ class UserInfoModel { username = other.username; Widget get avatarPainterWidget => SizedBox( - width: 50, - height: 50, + width: 50.sp, + height: 50.sp, child: CustomPaint(painter: CommonAvatarPainter(username: username)), ); diff --git a/lib/util/enter.dart b/lib/util/enter.dart index ea32df5f..270b602b 100644 --- a/lib/util/enter.dart +++ b/lib/util/enter.dart @@ -4,6 +4,7 @@ import 'dart:convert'; import 'dart:async'; import 'package:file_picker/file_picker.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:json_annotation/json_annotation.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:permission_handler/permission_handler.dart'; diff --git a/lib/util/toast.dart b/lib/util/toast.dart index 62f83a09..69a44c27 100644 --- a/lib/util/toast.dart +++ b/lib/util/toast.dart @@ -9,6 +9,6 @@ class Toast { timeInSecForIosWeb: 5, backgroundColor: Colors.black45, textColor: Colors.white, - fontSize: 16.0); + fontSize: ConstantFontSize.bodyLarge); } } diff --git a/lib/view/account/detail/account_detail.dart b/lib/view/account/detail/account_detail.dart index 1450195d..b74df126 100644 --- a/lib/view/account/detail/account_detail.dart +++ b/lib/view/account/detail/account_detail.dart @@ -1,6 +1,8 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; +import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; class AccountDetail extends StatelessWidget { @@ -19,55 +21,21 @@ class AccountDetail extends StatelessWidget { crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.all(16.0), + padding: EdgeInsets.all(Constant.padding), child: Text( account.name, - style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w500), + style: TextStyle(fontSize: 24, fontWeight: FontWeight.w500), ), ), - // Padding( - // padding: const EdgeInsets.symmetric(horizontal: 16.0), - // child: Text('类型:$bookType'), - // ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), + padding: EdgeInsets.all(Constant.padding), child: Text('更新日期:${DateFormat('yyyy-MM-dd HH:mm:ss').format(account.updateTime)}'), ), Padding( - padding: const EdgeInsets.symmetric(horizontal: 16.0), + padding: EdgeInsets.all(Constant.padding), child: Text('创建日期:${DateFormat('yyyy-MM-dd HH:mm:ss').format(account.createTime)}'), ), - // Padding( - // padding: const EdgeInsets.all(16.0), - // child: Text( - // '总金额:${totalAmount.toStringAsFixed(2)}', - // style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500), - // ), - // ), - const Divider( - thickness: 2, - ), - // Padding( - // padding: const EdgeInsets.all(16.0), - // child: Text( - // '最近交易记录', - // style: TextStyle(fontSize: 20, fontWeight: FontWeight.w500), - // ), - // ), - // ListView.builder( - // shrinkWrap: true, - // physics: NeverScrollableScrollPhysics(), - // itemCount: transactionRecords.length, - // itemBuilder: (context, index) { - // return ListTile( - // title: Text(transactionRecords[index].title), - // subtitle: Text(transactionRecords[index].date), - // trailing: Text( - // transactionRecords[index].amount.toStringAsFixed(2), - // ), - // ); - // }, - // ), + const Divider(thickness: 2), ], ), ), diff --git a/lib/view/account/edit/account_edit.dart b/lib/view/account/edit/account_edit.dart index 5c073e50..52466e0b 100644 --- a/lib/view/account/edit/account_edit.dart +++ b/lib/view/account/edit/account_edit.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/account/account_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; @@ -69,12 +70,12 @@ class AccountEditState extends State { appBar: AppBar( title: Text(mode == AccountEditMode.add ? "添加账本" : "编辑账本"), actions: [ - IconButton(icon: const Icon(Icons.save, size: 24), onPressed: _onSave), + IconButton(icon: Icon(Icons.save, size: 24), onPressed: _onSave), ], ), body: SingleChildScrollView( child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: buildForm(), ), ), @@ -90,16 +91,16 @@ class AccountEditState extends State { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.padding), child: CircularIcon(icon: account.icon), ), SizedBox( - width: 250, + width: 250.w, child: FormInputField.string('名称', account.name, (text) => account.name = text), ), - const SizedBox(height: Constant.padding), + SizedBox(height: Constant.padding), Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.margin), + padding: EdgeInsets.symmetric(horizontal: Constant.margin), child: FormSelecter.accountIcon(account.icon, onChanged: _onSelectIcon), ), _buildRadio(), @@ -134,7 +135,7 @@ class AccountEditState extends State { Widget _buildRadio() { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), child: Align( alignment: Alignment.centerLeft, child: Row( @@ -143,15 +144,15 @@ class AccountEditState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Text("类型", style: TextStyle(letterSpacing: Constant.margin / 2)), ), Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Row( children: [ SizedBox( - width: 100, + width: 100.sp, child: RadioListTile( contentPadding: EdgeInsets.zero, title: const Text("独立"), @@ -161,7 +162,7 @@ class AccountEditState extends State { ), ), SizedBox( - width: 100, + width: 100.sp, child: RadioListTile( title: const Text("共享"), contentPadding: EdgeInsets.zero, diff --git a/lib/view/account/list/account_list.dart b/lib/view/account/list/account_list.dart index d6a87080..c8b26cc1 100644 --- a/lib/view/account/list/account_list.dart +++ b/lib/view/account/list/account_list.dart @@ -51,14 +51,14 @@ class AccountListState extends State { final account = list[index]; return ListTile( leading: _buildLeading(account, selectedAccount.id), - contentPadding: const EdgeInsets.only(left: Constant.padding, right: Constant.smallPadding), + contentPadding: EdgeInsets.only(left: Constant.padding, right: Constant.smallPadding), horizontalTitleGap: 0, title: Row( mainAxisSize: MainAxisSize.min, children: [ Text( account.name, - style: const TextStyle(fontSize: ConstantFontSize.largeHeadline), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline), ), Visibility(visible: account.type == AccountType.share, child: const ShareLabel()), ], @@ -71,7 +71,7 @@ class AccountListState extends State { ), IconButton( onPressed: () async => _onClickAccount(list[index]), - icon: const Icon(Icons.more_vert, size: 32), + icon: Icon(Icons.more_vert, size: Constant.iconlargeSize), ) ]), ); diff --git a/lib/view/account/list/account_list_bottom_sheet.dart b/lib/view/account/list/account_list_bottom_sheet.dart index 4a62c977..1633b574 100644 --- a/lib/view/account/list/account_list_bottom_sheet.dart +++ b/lib/view/account/list/account_list_bottom_sheet.dart @@ -70,7 +70,7 @@ class _AccountListBottomSheetState extends State { return _buildAccount(list[index ~/ 2]); } else { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin), + padding: EdgeInsets.symmetric(vertical: Constant.margin), child: ConstantWidget.divider.indented, ); } @@ -94,7 +94,7 @@ class _AccountListBottomSheetState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Center( + Center( child: Padding( padding: EdgeInsets.all(Constant.margin), child: Text( @@ -114,7 +114,7 @@ class _AccountListBottomSheetState extends State { Widget _buildAccount(AccountDetailModel account) { return ListTile( horizontalTitleGap: 0, - contentPadding: const EdgeInsets.only(left: Constant.padding, right: Constant.smallPadding), + contentPadding: EdgeInsets.only(left: Constant.padding, right: Constant.smallPadding), leading: _buildLeading(account, selectedAccount.id), title: Row( children: [ diff --git a/lib/view/account/list/enter.dart b/lib/view/account/list/enter.dart index 5f72358c..951ffc4e 100644 --- a/lib/view/account/list/enter.dart +++ b/lib/view/account/list/enter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/bloc/account/account_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; @@ -18,11 +19,11 @@ enum ViewAccountListType { onlyCanEdit, all } Widget _buildLeading(AccountModel account, int selectAccountId) { return Row(mainAxisAlignment: MainAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ SizedBox( - width: 4, + width: Constant.margin / 2, child: Container(color: account.id == selectAccountId ? ConstantColor.primaryColor : Colors.white), ), - const SizedBox(width: Constant.margin), - Icon(account.icon, size: 32), - const SizedBox(width: Constant.margin), + SizedBox(width: Constant.margin), + Icon(account.icon, size: Constant.iconlargeSize), + SizedBox(width: Constant.margin), ]); } diff --git a/lib/view/account/list/widget/share_label.dart b/lib/view/account/list/widget/share_label.dart index 51c20d1e..4645b25b 100644 --- a/lib/view/account/list/widget/share_label.dart +++ b/lib/view/account/list/widget/share_label.dart @@ -5,6 +5,6 @@ class ShareLabel extends StatelessWidget { @override Widget build(BuildContext context) { - return const Padding(padding: EdgeInsets.only(left: Constant.margin), child: CommonLabel(text: "共享账本")); + return Padding(padding: EdgeInsets.only(left: Constant.margin), child: CommonLabel(text: "共享账本")); } } diff --git a/lib/view/account/mapping/account_mapping_bottom_sheet.dart b/lib/view/account/mapping/account_mapping_bottom_sheet.dart index 93a0948a..ee6fc6f6 100644 --- a/lib/view/account/mapping/account_mapping_bottom_sheet.dart +++ b/lib/view/account/mapping/account_mapping_bottom_sheet.dart @@ -46,7 +46,7 @@ class _AccountMappingBottomSheetState extends State { mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - const Center( + Center( child: Padding( padding: EdgeInsets.fromLTRB(Constant.margin, Constant.margin, Constant.margin, 0), child: Text( diff --git a/lib/view/account/operation/account_operation_bottom_sheet.dart b/lib/view/account/operation/account_operation_bottom_sheet.dart index 43a7be76..0dd64c17 100644 --- a/lib/view/account/operation/account_operation_bottom_sheet.dart +++ b/lib/view/account/operation/account_operation_bottom_sheet.dart @@ -55,7 +55,7 @@ class _AccountOperationBottomSheetState extends State onTap(), child: child, diff --git a/lib/view/account/template/list/account_template_list.dart b/lib/view/account/template/list/account_template_list.dart index 2b16c1e0..2052056b 100644 --- a/lib/view/account/template/list/account_template_list.dart +++ b/lib/view/account/template/list/account_template_list.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; @@ -48,7 +49,7 @@ class _AccountTemplateListBodyState extends State { if (state is AccountTemplateListLoaded) { return buildList(state.list); } - return buildShimmerList(); + return ShimmerList(); })); } @@ -62,7 +63,7 @@ class _AccountTemplateListBodyState extends State { ); }, separatorBuilder: (BuildContext context, int index) { - return Divider(color: Colors.grey.shade400, height: 1); + return Divider(color: Colors.grey.shade400, height: 1.sp); }); } @@ -76,13 +77,10 @@ class _AccountTemplateListBodyState extends State { triggerAddEvent(model); }, child: Container( - height: 100, + height: 100.h, decoration: BoxDecoration( - border: Border.all( - color: Colors.grey.shade300, - width: 2.0, - ), - borderRadius: BorderRadius.circular(12.0), + border: Border.all(color: Colors.grey.shade300, width: 2.0), + borderRadius: BorderRadius.circular(Constant.radius), ), margin: const EdgeInsets.all(16), child: Row( @@ -91,12 +89,12 @@ class _AccountTemplateListBodyState extends State { children: [ Icon( model.icon, - size: 32, + size: Constant.iconlargeSize, color: Colors.black54, ), Text( model.name, - style: const TextStyle(fontSize: 20, color: Colors.black87), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline, color: Colors.black87), ) ], )), diff --git a/lib/view/account/user/config/account_user_config_dialog.dart b/lib/view/account/user/config/account_user_config_dialog.dart index f39ecb6b..b2be1eb0 100644 --- a/lib/view/account/user/config/account_user_config_dialog.dart +++ b/lib/view/account/user/config/account_user_config_dialog.dart @@ -28,7 +28,7 @@ class AccountUserConfigDialogState extends State { child: BlocBuilder(builder: (context, state) { if (state is AccountUserConfigLoaded) { return AlertDialog( - contentPadding: const EdgeInsets.all(Constant.margin), + contentPadding: EdgeInsets.all(Constant.margin), content: Column( mainAxisSize: MainAxisSize.min, children: [..._buildFlags()], @@ -53,7 +53,7 @@ class AccountUserConfigDialogState extends State { Widget _buildFlag({required String title, required String flagName, required bool value, IconData? iconData}) { return CheckboxListTile( - contentPadding: const EdgeInsets.symmetric(horizontal: Constant.margin), + contentPadding: EdgeInsets.symmetric(horizontal: Constant.margin), value: value, title: Text(title), onChanged: (bool? value) { diff --git a/lib/view/account/user/detail/account_user_detail_buttom_sheet.dart b/lib/view/account/user/detail/account_user_detail_buttom_sheet.dart index 4845ad03..36b73f38 100644 --- a/lib/view/account/user/detail/account_user_detail_buttom_sheet.dart +++ b/lib/view/account/user/detail/account_user_detail_buttom_sheet.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; import 'package:leap_ledger_app/model/common/model.dart'; @@ -56,11 +57,11 @@ class _AccountUserDetailButtomSheetState extends State { subtitle: Text(accountUser.info.email)), ConstantWidget.divider.list, ListTile( - title: const Text("账本", style: TextStyle(fontSize: ConstantFontSize.body)), - trailing: Text(widget.account.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge)), + title: Text("账本", style: TextStyle(fontSize: ConstantFontSize.body)), + trailing: Text(widget.account.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge)), ), ConstantWidget.divider.list, ListTile( - title: const Text("角色", style: TextStyle(fontSize: ConstantFontSize.body)), + title: Text("角色", style: TextStyle(fontSize: ConstantFontSize.body)), trailing: DropdownButton( items: [ DropdownMenuItem( value: AccountRole.administrator, - child: Text(AccountRole.administrator.name, - style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.administrator.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), DropdownMenuItem( value: AccountRole.ownEditor, - child: - Text(AccountRole.ownEditor.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.ownEditor.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), DropdownMenuItem( value: AccountRole.reader, - child: Text(AccountRole.reader.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.reader.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), ], onChanged: (data) { if (data == null) { diff --git a/lib/view/account/user/invite/account_user_invite_dialog.dart b/lib/view/account/user/invite/account_user_invite_dialog.dart index bcdfac11..8b7b2bba 100644 --- a/lib/view/account/user/invite/account_user_invite_dialog.dart +++ b/lib/view/account/user/invite/account_user_invite_dialog.dart @@ -55,12 +55,12 @@ class _AccountUserInviteDialogState extends State { ListTile(leading: userInfo.avatarPainterWidget, title: Text(userInfo.username), subtitle: Text(userInfo.email)), ConstantWidget.divider.list, ListTile( - title: const Text("账本", style: TextStyle(fontSize: ConstantFontSize.body)), - trailing: Text(widget.account.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge)), + title: Text("账本", style: TextStyle(fontSize: ConstantFontSize.body)), + trailing: Text(widget.account.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge)), ), ConstantWidget.divider.list, ListTile( - title: const Text("角色", style: TextStyle(fontSize: ConstantFontSize.body)), + title: Text("角色", style: TextStyle(fontSize: ConstantFontSize.body)), trailing: _buildDropdownButton(), ), ]); @@ -72,14 +72,13 @@ class _AccountUserInviteDialogState extends State { items: [ DropdownMenuItem( value: AccountRole.administrator, - child: - Text(AccountRole.administrator.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.administrator.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), DropdownMenuItem( value: AccountRole.ownEditor, - child: Text(AccountRole.ownEditor.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.ownEditor.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), DropdownMenuItem( value: AccountRole.reader, - child: Text(AccountRole.reader.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge))), + child: Text(AccountRole.reader.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge))), ], onChanged: (data) { if (data == null) { @@ -91,6 +90,6 @@ class _AccountUserInviteDialogState extends State { value: selectedRole, ); } - return Text(AccountRole.ownEditor.name, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge)); + return Text(AccountRole.ownEditor.name, style: TextStyle(fontSize: ConstantFontSize.bodyLarge)); } } diff --git a/lib/view/home/home.dart b/lib/view/home/home.dart index dd4525d0..a8af35c4 100644 --- a/lib/view/home/home.dart +++ b/lib/view/home/home.dart @@ -26,112 +26,109 @@ class _HomeState extends State { @override Widget build(BuildContext context) { - return Container( - color: ConstantColor.greyBackground, - child: RefreshIndicator( - onRefresh: () async => _bloc.add(HomeFetchDataEvent()), - child: SingleChildScrollView( - child: BlocProvider.value( - value: _bloc, - child: MultiBlocListener( - listeners: [ - BlocListener( - listenWhen: (_, state) => state is CurrentAccountChanged, - listener: (_, state) => _bloc.add(HomeAccountChangeEvent(account: UserBloc.currentAccount)), - ), - BlocListener( - listenWhen: (_, state) => state is AccountTransCategoryInitSuccess, - listener: (context, state) { - if (state is AccountTransCategoryInitSuccess) _bloc.add(HomeFetchCategoryAmountRankDataEvent()); - }, - ), - BlocListener( - listenWhen: (_, state) => state is CategoryOfAccountState && state.account.id == _bloc.account.id, - listener: (context, state) { - if (state is CategoryOfAccountState) _bloc.add(HomeFetchCategoryAmountRankDataEvent()); - }, - ), - BlocListener( - listenWhen: (_, state) => state is TransactionStatisticUpdate, - listener: (context, state) { - if (state is TransactionStatisticUpdate) { - _bloc.add(HomeStatisticUpdateEvent(state.oldTrans, state.newTrans)); - } - }, - ), - ], - child: _buildContent(), - )), - ), - ), - ); - } - - Widget _buildContent() { - return Column( - mainAxisSize: MainAxisSize.min, - children: [ - Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), - child: SafeArea( - child: BlocBuilder( - buildWhen: (_, state) => state is HomeHeaderLoaded, - builder: (context, state) { - if (state is HomeHeaderLoaded) { - return HeaderCard(data: state.data); - } - return HeaderCard(); - }, - ), + return BlocProvider.value( + value: _bloc, + child: MultiBlocListener( + listeners: [ + BlocListener( + listenWhen: (_, state) => state is CurrentAccountChanged, + listener: (_, state) => _bloc.add(HomeAccountChangeEvent(account: UserBloc.currentAccount)), ), - ), - SizedBox(height: Constant.margin), - BlocBuilder( - buildWhen: (_, state) => state is CurrentAccountChanged, - builder: (context, state) { - return HomeNavigation(account: UserBloc.currentAccount); - }, - ), - SizedBox(height: Constant.margin), - Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), - child: BlocBuilder( - buildWhen: (_, state) => state is HomeTimePeriodStatisticsLoaded, - builder: (context, state) { - if (state is HomeTimePeriodStatisticsLoaded) { - return TimePeriodStatistics( - data: state.data, - ); - } - return TimePeriodStatistics(); + BlocListener( + listenWhen: (_, state) => state is AccountTransCategoryInitSuccess, + listener: (context, state) { + if (state is AccountTransCategoryInitSuccess) _bloc.add(HomeFetchCategoryAmountRankDataEvent()); }, ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), - child: BlocBuilder( - buildWhen: (_, state) => state is HomeStatisticsLineChart, - builder: (context, state) { - if (state is HomeStatisticsLineChart) { - return StatisticsLineChart(data: state.expenseList); - } - return StatisticsLineChart(data: []); + BlocListener( + listenWhen: (_, state) => state is CategoryOfAccountState && state.account.id == _bloc.account.id, + listener: (context, state) { + if (state is CategoryOfAccountState) _bloc.add(HomeFetchCategoryAmountRankDataEvent()); }, ), - ), - Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), - child: BlocBuilder( - buildWhen: (_, state) => state is HomeCategoryAmountRank, - builder: (context, state) { - if (state is HomeCategoryAmountRank) { - return CategoryAmountRank(data: state.rankingList); + BlocListener( + listenWhen: (_, state) => state is TransactionStatisticUpdate, + listener: (context, state) { + if (state is TransactionStatisticUpdate) { + _bloc.add(HomeStatisticUpdateEvent(state.oldTrans, state.newTrans)); } - return CategoryAmountRank(data: []); }, ), - ) - ], + ], + child: _buildContent(), + ), + ); + } + + Widget _buildContent() { + return DecoratedBox( + decoration: BoxDecoration(color: ConstantColor.greyBackground), + child: RefreshIndicator( + onRefresh: () async => _bloc.add(HomeFetchDataEvent()), + child: ListView( + children: [ + Padding( + padding: EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), + child: SafeArea( + child: BlocBuilder( + buildWhen: (_, state) => state is HomeHeaderLoaded, + builder: (context, state) { + if (state is HomeHeaderLoaded) { + return HeaderCard(data: state.data); + } + return HeaderCard(); + }, + ), + ), + ), + SizedBox(height: Constant.margin / 2), + BlocBuilder( + buildWhen: (_, state) => state is CurrentAccountChanged, + builder: (context, state) { + return HomeNavigation(account: UserBloc.currentAccount); + }, + ), + SizedBox(height: Constant.margin / 2), + Padding( + padding: EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), + child: BlocBuilder( + buildWhen: (_, state) => state is HomeTimePeriodStatisticsLoaded, + builder: (context, state) { + if (state is HomeTimePeriodStatisticsLoaded) { + return TimePeriodStatistics( + data: state.data, + ); + } + return TimePeriodStatistics(); + }, + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), + child: BlocBuilder( + buildWhen: (_, state) => state is HomeStatisticsLineChart, + builder: (context, state) { + if (state is HomeStatisticsLineChart) { + return StatisticsLineChart(data: state.expenseList); + } + return StatisticsLineChart(data: []); + }, + ), + ), + Padding( + padding: EdgeInsets.symmetric(horizontal: Constant.padding, vertical: 0), + child: BlocBuilder( + buildWhen: (_, state) => state is HomeCategoryAmountRank, + builder: (context, state) { + if (state is HomeCategoryAmountRank) { + return CategoryAmountRank(data: state.rankingList); + } + return CategoryAmountRank(data: []); + }, + ), + ) + ], + )), ); } } diff --git a/lib/view/home/widget/category_amount_rank.dart b/lib/view/home/widget/category_amount_rank.dart index 3bd5df0d..165a53a6 100644 --- a/lib/view/home/widget/category_amount_rank.dart +++ b/lib/view/home/widget/category_amount_rank.dart @@ -78,14 +78,15 @@ class _CategoryAmountRankState extends State with SingleTick leading: Icon(data.category.icon, color: ConstantColor.primaryColor), title: Text( data.category.name, - style: const TextStyle(fontSize: ConstantFontSize.body), + style: TextStyle(fontSize: ConstantFontSize.body), ), subtitle: data.amount != 0 ? _buildProgress(data.amount / maxAmount) : _buildProgress(0), trailing: Padding( padding: EdgeInsets.zero, child: AmountText.sameHeight( data.amount, - textStyle: const TextStyle(fontSize: 16, fontWeight: FontWeight.normal, color: Colors.black87), + textStyle: + TextStyle(fontSize: ConstantFontSize.bodyLarge, fontWeight: FontWeight.normal, color: Colors.black87), ), ), )); @@ -112,7 +113,7 @@ class AmountDivider extends StatelessWidget { double currentWidth = constraints.maxWidth; return Divider( color: ConstantColor.secondaryColor, - height: 0.5, + height: 0.5.sp, thickness: 5, endIndent: currentWidth - currentWidth * proportion); }, diff --git a/lib/view/home/widget/enter.dart b/lib/view/home/widget/enter.dart index 2848d091..96b4fc8c 100644 --- a/lib/view/home/widget/enter.dart +++ b/lib/view/home/widget/enter.dart @@ -16,6 +16,7 @@ import 'package:leap_ledger_app/widget/amount/enter.dart'; import 'package:leap_ledger_app/widget/common/common.dart'; import 'package:timezone/timezone.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; part 'statistics_line_chart.dart'; part 'header_card.dart'; part 'time_period_statistics.dart'; @@ -28,10 +29,10 @@ class _Func { return Card( color: background ?? Colors.white, elevation: 0, - shape: const RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: ConstantDecoration.borderRadius, ), - margin: const EdgeInsets.symmetric(vertical: Constant.margin), + margin: EdgeInsets.symmetric(vertical: Constant.margin), child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, @@ -39,10 +40,10 @@ class _Func { ? [child] : [ Padding( - padding: const EdgeInsets.only(top: Constant.padding / 4 * 3, left: Constant.padding), + padding: EdgeInsets.only(top: Constant.padding / 4 * 3, left: Constant.padding), child: Text( title, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), ), ), child diff --git a/lib/view/home/widget/header_card.dart b/lib/view/home/widget/header_card.dart index d6d104e0..fb7a7980 100644 --- a/lib/view/home/widget/header_card.dart +++ b/lib/view/home/widget/header_card.dart @@ -42,7 +42,7 @@ class _HeaderCardState extends State { ), child: _Func._buildCard( background: ConstantColor.primaryColor, - child: Container(padding: const EdgeInsets.all(Constant.padding), child: _buildContent()), + child: Container(padding: EdgeInsets.all(Constant.padding), child: _buildContent()), ), ); } @@ -54,7 +54,7 @@ class _HeaderCardState extends State { Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - const Text('本月支出', style: TextStyle(fontSize: ConstantFontSize.headline)), + Text('本月支出', style: TextStyle(fontSize: ConstantFontSize.headline)), _buildDate(data.startTime, data.endTime), ], ), @@ -63,7 +63,7 @@ class _HeaderCardState extends State { children: [ UnequalHeightAmountTextSpan( amount: data.expense.amount, - textStyle: const TextStyle(fontSize: 34.0, fontWeight: FontWeight.w500, color: Colors.black), + textStyle: TextStyle(fontSize: 34, fontWeight: FontWeight.w500, color: Colors.black), dollarSign: true, tailReduction: false, ), @@ -76,17 +76,15 @@ class _HeaderCardState extends State { amount: data.income.amount, title: '本月收入', dollarSign: true, - textStyle: const TextStyle(fontSize: ConstantFontSize.headline, color: Colors.black), + textStyle: TextStyle(fontSize: ConstantFontSize.headline, color: Colors.black), tailReduction: false, ), - const SizedBox( - width: 20, - ), + SizedBox(width: 20.w), UnequalHeightAmountTextSpan( amount: data.dayAverageExpense, title: '日均支出', dollarSign: true, - textStyle: const TextStyle(fontSize: ConstantFontSize.headline, color: Colors.black), + textStyle: TextStyle(fontSize: ConstantFontSize.headline, color: Colors.black), tailReduction: false, ) ], @@ -96,21 +94,17 @@ class _HeaderCardState extends State { } Widget _buildDate(DateTime start, DateTime end) { - return Column( - children: [ - Container( - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(Constant.smallPadding * 2), - color: ConstantColor.secondaryColor, - ), - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), - child: Text( - "${_bloc.account.timeLocation.name} ${DateFormat.MMMd().format(_bloc.getTZDateTime(start))} - ${DateFormat.MMMd().format(_bloc.getTZDateTime(end))}", - style: const TextStyle(fontSize: ConstantFontSize.body), - ), - ) - ], + return Container( + decoration: BoxDecoration( + shape: BoxShape.rectangle, + borderRadius: BorderRadius.circular(Constant.smallPadding * 2), + color: ConstantColor.secondaryColor, + ), + padding: EdgeInsets.symmetric(horizontal: Constant.margin * 1.5), + child: Text( + "${_bloc.account.timeLocation.name} ${DateFormat.MMMd().format(_bloc.getTZDateTime(start))} - ${DateFormat.MMMd().format(_bloc.getTZDateTime(end))}", + style: TextStyle(fontSize: ConstantFontSize.body), + ), ); } } diff --git a/lib/view/home/widget/home_navigation.dart b/lib/view/home/widget/home_navigation.dart index 42bc2672..12e7aed0 100644 --- a/lib/view/home/widget/home_navigation.dart +++ b/lib/view/home/widget/home_navigation.dart @@ -6,11 +6,13 @@ class HomeNavigation extends StatelessWidget { @override Widget build(BuildContext context) { return SizedBox( - height: 48, + height: 48.sp, width: MediaQuery.of(context).size.width, child: ListView( scrollDirection: Axis.horizontal, + padding: EdgeInsets.zero, children: [ + SizedBox(width: Constant.margin / 2), _navigatorButton( account.name, icon: Icons.sync_outlined, @@ -38,7 +40,8 @@ class HomeNavigation extends StatelessWidget { icon: Icons.upload_outlined, onTap: () => TransactionRoutes.import(context, account: account).push(), ), - ) + ), + SizedBox(width: Constant.margin / 2), ], ), ); @@ -48,27 +51,24 @@ class HomeNavigation extends StatelessWidget { return GestureDetector( onTap: onTap, child: Container( - margin: const EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), - decoration: const BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.all(Radius.circular(90)), - ), - alignment: Alignment.center, - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Icon( - icon, - color: ConstantColor.primaryColor, - size: 24, - ), - const SizedBox(width: Constant.margin / 2), - Text(title), - ], - )), + margin: EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.all(Radius.circular(90.w)), + ), + alignment: Alignment.center, + child: Row( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Icon(icon, color: ConstantColor.primaryColor, size: Constant.iconSize), + SizedBox(width: Constant.margin / 2), + Text(title), + ], + ), + ), ); } } diff --git a/lib/view/home/widget/statistics_line_chart.dart b/lib/view/home/widget/statistics_line_chart.dart index eba01547..557dddd2 100644 --- a/lib/view/home/widget/statistics_line_chart.dart +++ b/lib/view/home/widget/statistics_line_chart.dart @@ -32,7 +32,7 @@ class _StatisticsLineChartState extends State { child: AspectRatio( aspectRatio: 1.6, child: Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: _buildLineChart(), ), ), @@ -97,7 +97,7 @@ class _StatisticsLineChartState extends State { showTitles: true, getTitlesWidget: (value, context) { return Text(DateFormat('d日').format(_bloc.getTZDateTime(data[value.toInt()].date)), - style: const TextStyle( + style: TextStyle( color: Colors.grey, fontSize: ConstantFontSize.bodySmall, )); diff --git a/lib/view/home/widget/time_period_statistics.dart b/lib/view/home/widget/time_period_statistics.dart index e5a12c10..502a44d3 100644 --- a/lib/view/home/widget/time_period_statistics.dart +++ b/lib/view/home/widget/time_period_statistics.dart @@ -53,7 +53,7 @@ class _TimePeriodStatisticsState extends State { return _Func._buildCard( title: "收支报告", child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -96,16 +96,16 @@ class _TimePeriodStatisticsState extends State { dense: true, leading: Icon( icon, - size: 30, + size: Constant.iconlargeSize, color: ConstantColor.primaryColor, ), title: Text( title, - style: const TextStyle(fontSize: ConstantFontSize.headline), + style: TextStyle(fontSize: ConstantFontSize.headline), ), subtitle: Text( date, - style: const TextStyle(fontSize: ConstantFontSize.bodySmall, color: ConstantColor.greyText), + style: TextStyle(fontSize: ConstantFontSize.bodySmall, color: ConstantColor.greyText), ), trailing: Column( mainAxisSize: MainAxisSize.min, @@ -133,7 +133,7 @@ class _TimePeriodStatisticsState extends State { color: color, ), ), - const SizedBox(width: Constant.margin / 2), + SizedBox(width: Constant.margin / 2), Text(name, style: const TextStyle(color: ConstantColor.greyText)), ], ); diff --git a/lib/view/navigation/navigation.dart b/lib/view/navigation/navigation.dart index d6b29a4e..d1e11b3b 100644 --- a/lib/view/navigation/navigation.dart +++ b/lib/view/navigation/navigation.dart @@ -1,3 +1,5 @@ +import 'dart:math'; + import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; @@ -11,7 +13,7 @@ import 'package:leap_ledger_app/util/enter.dart'; import 'package:leap_ledger_app/view/home/home.dart'; import 'package:leap_ledger_app/view/share/home/share_home.dart'; import 'package:leap_ledger_app/widget/common/common.dart'; - +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'bloc/navigation_bloc.dart'; part 'widget/user_drawer.dart'; @@ -31,11 +33,9 @@ class _NavigationState extends State { @override void initState() { - UserBloc.checkUserState(context); + super.initState(); _bloc = NavigationBloc(account: UserBloc.currentAccount); _pages = [Home(), ShareHome()]; - - super.initState(); } @override @@ -134,7 +134,7 @@ class _BottomNavigationBarState extends State<_BottomNavigationBar> { surfaceTintColor: Colors.white, color: Colors.white, shadowColor: Colors.grey, - height: 52, + height: 52.sp, padding: EdgeInsets.zero, shape: CircularNotchedRectangle(), elevation: Constant.margin, diff --git a/lib/view/navigation/widget/user_drawer.dart b/lib/view/navigation/widget/user_drawer.dart index 1ed26369..4fc12355 100644 --- a/lib/view/navigation/widget/user_drawer.dart +++ b/lib/view/navigation/widget/user_drawer.dart @@ -6,8 +6,9 @@ class UserDrawer extends StatelessWidget { @override Widget build(BuildContext context) { final Color iconColor = Colors.grey.shade800; + final double leftPadding = 48.w; return Drawer( - width: 280, + width: max(MediaQuery.of(context).size.width * 2 / 3, 200.w), backgroundColor: Colors.white, child: DefaultTextStyle( style: TextStyle(color: iconColor), @@ -18,7 +19,7 @@ class UserDrawer extends StatelessWidget { ListTile( leading: Icon(Icons.key, color: iconColor), title: const Text('修改密码'), - contentPadding: const EdgeInsets.only(left: 48), + contentPadding: EdgeInsets.only(left: leftPadding), onTap: () { Navigator.pushNamed(context, UserRoutes.passwordUpdate); }, @@ -26,13 +27,13 @@ class UserDrawer extends StatelessWidget { ListTile( leading: Icon(Icons.library_books, color: iconColor), title: const Text('账本管理'), - contentPadding: const EdgeInsets.only(left: 48), + contentPadding: EdgeInsets.only(left: leftPadding), onTap: () => AccountRoutes.list(context, selectedCurrentAccount: true).push(), ), ListTile( leading: Icon(Icons.toggle_on_outlined, color: iconColor), title: const Text('分享配置'), - contentPadding: const EdgeInsets.only(left: 48), + contentPadding: EdgeInsets.only(left: leftPadding), onTap: () { Navigator.pushNamed(context, UserRoutes.configTransactionShare); }, @@ -40,7 +41,7 @@ class UserDrawer extends StatelessWidget { ListTile( leading: Icon(Icons.send_outlined, color: iconColor), title: const Text('邀请'), - contentPadding: const EdgeInsets.only(left: 48), + contentPadding: EdgeInsets.only(left: leftPadding), onTap: () { Navigator.pushNamed(context, UserRoutes.accountInvitation); }, @@ -48,7 +49,7 @@ class UserDrawer extends StatelessWidget { ListTile( leading: Icon(Icons.logout_outlined, color: iconColor), title: const Text('退出'), - contentPadding: const EdgeInsets.only(left: 48), + contentPadding: EdgeInsets.only(left: leftPadding), onTap: () { BlocProvider.of(context).add(UserLogoutEvent()); Navigator.popAndPushNamed(context, UserRoutes.login); diff --git a/lib/view/navigation/widget/user_drawer_header.dart b/lib/view/navigation/widget/user_drawer_header.dart index 4f920fa1..61b73c16 100644 --- a/lib/view/navigation/widget/user_drawer_header.dart +++ b/lib/view/navigation/widget/user_drawer_header.dart @@ -25,7 +25,8 @@ class _UserDrawerHeaderState extends State { mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - const CircleAvatar(backgroundImage: null, radius: 32.0, child: Icon(Icons.person, size: 32.0)), + CircleAvatar( + backgroundImage: null, radius: 32.0.w, child: Icon(Icons.person, size: Constant.iconlargeSize)), Expanded( child: Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -71,18 +72,14 @@ class _UserDrawerHeaderState extends State { children: [ Text( user.username, - style: const TextStyle(color: Colors.white, fontSize: 24.0, fontWeight: FontWeight.w500), + style: TextStyle(color: Colors.white, fontSize: 24.0, fontWeight: FontWeight.w500), ), GestureDetector( onTap: () { Clipboard.setData(ClipboardData(text: user.uniqueUsername)); CommonToast.tipToast("用户名已复制"); }, - child: Icon( - Icons.copy_outlined, - color: Colors.white, - size: 16, - )) + child: Icon(Icons.copy_outlined, color: Colors.white, size: 18)) ], ))); } @@ -96,14 +93,14 @@ class _UserDrawerHeaderState extends State { alignment: Alignment.centerLeft, child: Text( splitStrings[0], - style: const TextStyle(fontSize: ConstantFontSize.body), + style: TextStyle(fontSize: ConstantFontSize.body), ), ), Align( alignment: Alignment.centerRight, child: Text( "@${splitStrings[1]}", - style: const TextStyle(fontSize: ConstantFontSize.bodySmall), + style: TextStyle(fontSize: ConstantFontSize.bodySmall), )) ], ); @@ -112,7 +109,7 @@ class _UserDrawerHeaderState extends State { children: [ Text( email, - style: const TextStyle(fontSize: ConstantFontSize.body), + style: TextStyle(fontSize: ConstantFontSize.body), ) ], ); diff --git a/lib/view/share/home/share_home.dart b/lib/view/share/home/share_home.dart index 5d1e5c3e..6a1b45ed 100644 --- a/lib/view/share/home/share_home.dart +++ b/lib/view/share/home/share_home.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/transaction/transaction_bloc.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; @@ -70,7 +71,7 @@ class _ShareHomeState extends State { return ShareHomeBloc.account == null ? SizedBox() : Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Text("${ShareHomeBloc.account!.timeLocation.name}"), ); }) @@ -82,7 +83,7 @@ class _ShareHomeState extends State { body: RefreshIndicator( onRefresh: () async => _bloc.add(LoadShareHomeEvent()), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.margin), + padding: EdgeInsets.symmetric(horizontal: Constant.margin), child: _buildContent(), ), ), @@ -95,7 +96,7 @@ class _ShareHomeState extends State { Widget _buildContent() { return CustomScrollView( slivers: [ - SliverPadding(padding: const EdgeInsets.only(top: Constant.margin)), + SliverPadding(padding: EdgeInsets.only(top: Constant.margin)), SliverToBoxAdapter( child: BlocBuilder( buildWhen: (previous, current) => current is AccountTotalLoaded, @@ -108,10 +109,10 @@ class _ShareHomeState extends State { })), ), SliverPadding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), sliver: SliverToBoxAdapter( child: SizedBox( - height: 48, + height: 48.sp, width: MediaQuery.of(context).size.width, child: _buildOperationalNavigation(), )), @@ -189,8 +190,8 @@ class _ShareHomeState extends State { return GestureDetector( onTap: onTap, child: Container( - margin: const EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + margin: EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(90)), @@ -201,14 +202,8 @@ class _ShareHomeState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon( - icon, - color: ConstantColor.primaryColor, - size: 24, - ), - const SizedBox( - width: Constant.margin / 2, - ), + Icon(icon, color: ConstantColor.primaryColor, size: Constant.iconSize), + SizedBox(width: Constant.margin / 2), Text(text), ], )), @@ -219,8 +214,8 @@ class _ShareHomeState extends State { return GestureDetector( onTap: onTap, child: Container( - margin: const EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + margin: EdgeInsets.only(left: Constant.margin / 2, right: Constant.margin / 2), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(90)), @@ -231,14 +226,8 @@ class _ShareHomeState extends State { crossAxisAlignment: CrossAxisAlignment.center, mainAxisSize: MainAxisSize.min, children: [ - Icon( - icon, - color: ConstantColor.primaryColor, - size: 24, - ), - const SizedBox( - width: Constant.margin / 2, - ), + Icon(icon, color: ConstantColor.primaryColor, size: Constant.iconSize), + SizedBox(width: Constant.margin / 2), Text(text), ], )), diff --git a/lib/view/share/home/widget/account_menu.dart b/lib/view/share/home/widget/account_menu.dart index 00ef033c..777ed88a 100644 --- a/lib/view/share/home/widget/account_menu.dart +++ b/lib/view/share/home/widget/account_menu.dart @@ -33,7 +33,7 @@ class _AccountMenuState extends State { return _buildCreateBox(); } else if (state is AccountListLoaded) { return DefaultTextStyle.merge( - style: const TextStyle(fontSize: ConstantFontSize.largeHeadline), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline), child: PopupMenuButton( itemBuilder: (context) { return List.generate( @@ -68,7 +68,7 @@ class _AccountMenuState extends State { crossAxisAlignment: CrossAxisAlignment.center, children: [ Icon(account.icon, size: ConstantFontSize.largeHeadline), - const SizedBox(width: Constant.margin / 2), + SizedBox(width: Constant.margin / 2), Text(account.name, textAlign: TextAlign.center) ], ); @@ -76,12 +76,12 @@ class _AccountMenuState extends State { Widget _buildCreateBox() { return Container( - margin: const EdgeInsets.all(Constant.margin), + margin: EdgeInsets.all(Constant.margin), decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade400), borderRadius: ConstantDecoration.borderRadius, ), - child: const Padding( + child: Padding( padding: EdgeInsets.all(Constant.padding), child: Column( children: [Text("新建共享账本"), Icon(ConstantIcon.add)], diff --git a/lib/view/share/home/widget/account_total.dart b/lib/view/share/home/widget/account_total.dart index a18908f0..c23bdbd7 100644 --- a/lib/view/share/home/widget/account_total.dart +++ b/lib/view/share/home/widget/account_total.dart @@ -18,9 +18,9 @@ class AccountTotal extends StatelessWidget { Widget _buildTotal(IconData icon, String text, InExStatisticModel data) { return Expanded( child: Container( - padding: const EdgeInsets.all(Constant.padding), - margin: const EdgeInsets.all(Constant.margin), - decoration: const BoxDecoration(borderRadius: ConstantDecoration.borderRadius, color: Colors.white), + padding: EdgeInsets.all(Constant.padding), + margin: EdgeInsets.all(Constant.margin), + decoration: BoxDecoration(borderRadius: ConstantDecoration.borderRadius, color: Colors.white), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceAround, @@ -30,7 +30,7 @@ class AccountTotal extends StatelessWidget { Icon(icon, size: 36, color: ConstantColor.primaryColor), Text( text, - style: const TextStyle( + style: TextStyle( fontSize: ConstantFontSize.body, color: ConstantColor.greyText, letterSpacing: ConstantFontSize.letterSpacing, @@ -51,7 +51,7 @@ class AccountTotal extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ _buildAmount(data.expense.amount, IncomeExpense.expense), - const SizedBox(height: Constant.margin / 2), + SizedBox(height: Constant.margin / 2), _buildAmount(data.income.amount, IncomeExpense.income), ], ), @@ -80,7 +80,7 @@ class AccountTotal extends StatelessWidget { } Widget _buildIe() { - return const Column( + return Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/view/share/home/widget/account_user_card.dart b/lib/view/share/home/widget/account_user_card.dart index 020ce727..aaaf942f 100644 --- a/lib/view/share/home/widget/account_user_card.dart +++ b/lib/view/share/home/widget/account_user_card.dart @@ -35,10 +35,7 @@ class _AccountUserCardState extends State { itemCount: state.list.length, ); } - return const SizedBox( - width: double.infinity, - height: 50, - ); + return SizedBox(width: double.infinity, height: 50.sp); }, ), action: Offstage( diff --git a/lib/view/share/home/widget/enter.dart b/lib/view/share/home/widget/enter.dart index a69a2e20..6e7f3036 100644 --- a/lib/view/share/home/widget/enter.dart +++ b/lib/view/share/home/widget/enter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; @@ -27,10 +28,10 @@ class _Func { ? [child] : [ Padding( - padding: const EdgeInsets.only(top: Constant.padding, left: Constant.padding), + padding: EdgeInsets.only(top: Constant.padding, left: Constant.padding), child: Text( title, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), ), ), child @@ -44,11 +45,9 @@ class _Func { } return Card( color: background ?? Colors.white, - margin: const EdgeInsets.all(Constant.margin), + margin: EdgeInsets.all(Constant.margin), elevation: 0, - shape: const RoundedRectangleBorder( - borderRadius: ConstantDecoration.borderRadius, - ), + shape: RoundedRectangleBorder(borderRadius: ConstantDecoration.borderRadius), child: child, ); } diff --git a/lib/view/share/home/widget/no_account_page.dart b/lib/view/share/home/widget/no_account_page.dart index f42ecd00..67c993b6 100644 --- a/lib/view/share/home/widget/no_account_page.dart +++ b/lib/view/share/home/widget/no_account_page.dart @@ -43,14 +43,14 @@ class NoAccountPage extends StatelessWidget { return SizedBox( width: double.infinity, child: Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: GestureDetector( onTap: () => onTap(), child: DecoratedBox( decoration: BoxDecoration( border: Border.all(color: Colors.grey.shade200), borderRadius: ConstantDecoration.borderRadius), child: Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, diff --git a/lib/view/transaction/category/edit/transaction_category_edit.dart b/lib/view/transaction/category/edit/transaction_category_edit.dart index 457e76ca..7613f016 100644 --- a/lib/view/transaction/category/edit/transaction_category_edit.dart +++ b/lib/view/transaction/category/edit/transaction_category_edit.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/category/category_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/account/model.dart'; @@ -49,7 +50,7 @@ class _TransactionCategoryEditState extends State { title: Text(data.isValid ? '编辑二级类型' : '新建二级类型'), actions: [ IconButton( - icon: const Icon(Icons.save_outlined, size: Constant.iconSize), + icon: Icon(Icons.save_outlined, size: Constant.iconSize), onPressed: () => _bloc.add(CategorySaveEvent(widget.account, category: data)), ), ], @@ -62,7 +63,7 @@ class _TransactionCategoryEditState extends State { return Form( key: _formKey, child: Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Column( children: [ Container( @@ -70,13 +71,13 @@ class _TransactionCategoryEditState extends State { color: Colors.blue, borderRadius: BorderRadius.circular(90), ), - margin: const EdgeInsets.only(bottom: Constant.padding), - width: 64, - height: 64, - child: Icon(data.icon, size: 32, color: Colors.black87), + margin: EdgeInsets.only(bottom: Constant.padding), + width: 64.sp, + height: 64.sp, + child: Icon(data.icon, size: Constant.iconlargeSize, color: Colors.black87), ), FormInputField.string('名称', data.name, (text) => data.name = text), - const SizedBox(height: Constant.padding), + SizedBox(height: Constant.padding), FormSelecter.transactionCategoryIcon(data.icon, onChanged: _onSelectIcon), ], ), diff --git a/lib/view/transaction/category/mapping/weiget/enter.dart b/lib/view/transaction/category/mapping/weiget/enter.dart index 0389159d..7ade044a 100644 --- a/lib/view/transaction/category/mapping/weiget/enter.dart +++ b/lib/view/transaction/category/mapping/weiget/enter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/common/model.dart'; import 'package:leap_ledger_app/model/transaction/category/model.dart'; diff --git a/lib/view/transaction/category/mapping/weiget/header_card.dart b/lib/view/transaction/category/mapping/weiget/header_card.dart index 9a0c549a..3c3d2c47 100644 --- a/lib/view/transaction/category/mapping/weiget/header_card.dart +++ b/lib/view/transaction/category/mapping/weiget/header_card.dart @@ -26,7 +26,7 @@ class HeaderCard extends StatelessWidget { return Chip( label: Text( model.name, - style: const TextStyle(fontSize: ConstantFontSize.bodySmall), + style: TextStyle(fontSize: ConstantFontSize.bodySmall), ), padding: const EdgeInsets.all(0), backgroundColor: Colors.white, diff --git a/lib/view/transaction/category/mapping/weiget/option_bottom_sheet.dart b/lib/view/transaction/category/mapping/weiget/option_bottom_sheet.dart index 063c39b9..724b887d 100644 --- a/lib/view/transaction/category/mapping/weiget/option_bottom_sheet.dart +++ b/lib/view/transaction/category/mapping/weiget/option_bottom_sheet.dart @@ -7,7 +7,7 @@ class OptionBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { return Container( - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Colors.white, borderRadius: ConstantDecoration.bottomSheetBorderRadius, ), @@ -23,7 +23,7 @@ class OptionBottomSheet extends StatelessWidget { ); }, separatorBuilder: (BuildContext context, int index) { - return const Divider(color: Colors.grey, height: 0.5, thickness: 0.5, indent: 16, endIndent: 16); + return Divider(color: Colors.grey, height: 0.5.sp, thickness: 0.5.sp, indent: 16.sp, endIndent: 16.sp); }, itemCount: unmapped.length, )), diff --git a/lib/view/transaction/category/mapping/weiget/tab_view.dart b/lib/view/transaction/category/mapping/weiget/tab_view.dart index ab41b494..2441bbda 100644 --- a/lib/view/transaction/category/mapping/weiget/tab_view.dart +++ b/lib/view/transaction/category/mapping/weiget/tab_view.dart @@ -42,12 +42,12 @@ class _TabViewState extends State with AutomaticKeepAliveClientMixin { slivers: [ SliverToBoxAdapter( child: Padding( - padding: const EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), + padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), child: HeaderCard(state.unmapped), ), ), SliverPadding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), sliver: buildList(state.relation), ), ], @@ -81,13 +81,13 @@ class _TabViewState extends State with AutomaticKeepAliveClientMixin { childrenWidget.add(buildCategory(childList[i], relation[childList[i].id])); } return Padding( - padding: const EdgeInsets.only(top: Constant.margin), + padding: EdgeInsets.only(top: Constant.margin), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - Padding(padding: const EdgeInsets.all(Constant.margin), child: Text(father.name)), + Padding(padding: EdgeInsets.all(Constant.margin), child: Text(father.name)), Container( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), width: double.infinity, decoration: ConstantDecoration.cardDecoration, child: Column( @@ -110,7 +110,7 @@ class _TabViewState extends State with AutomaticKeepAliveClientMixin { ..layout()) .size; return ListTile( - contentPadding: const EdgeInsets.all(0), + contentPadding: EdgeInsets.zero, minVerticalPadding: 0, dense: true, leading: Row( @@ -130,9 +130,9 @@ class _TabViewState extends State with AutomaticKeepAliveClientMixin { (index) => GestureDetector( onTap: () => onDelete(category, relation[index]), child: Chip( - label: Text(relation![index].name, style: const TextStyle(fontSize: ConstantFontSize.bodySmall)), - padding: const EdgeInsets.all(0), - shape: const RoundedRectangleBorder( + label: Text(relation![index].name, style: TextStyle(fontSize: ConstantFontSize.bodySmall)), + padding: EdgeInsets.zero, + shape: RoundedRectangleBorder( borderRadius: ConstantDecoration.borderRadius, ), backgroundColor: ConstantColor.greyButton, diff --git a/lib/view/transaction/category/template/transaction_category_template.dart b/lib/view/transaction/category/template/transaction_category_template.dart index 6f0e9dd8..9acfafe5 100644 --- a/lib/view/transaction/category/template/transaction_category_template.dart +++ b/lib/view/transaction/category/template/transaction_category_template.dart @@ -65,7 +65,7 @@ class _TransactionCategoryTemplateState extends State onSelect(account), child: DecoratedBox( @@ -79,7 +79,7 @@ class _TransactionCategoryTemplateState extends State with AutomaticKeep return BlocBuilder( builder: (context, state) { if (state is LoadingState) { - return buildShimmerList(); + return ShimmerList(); } else if (state is LoadedState) { return _buildDragAndDropLists(); } @@ -37,13 +37,13 @@ class _DragAndDropListsState extends State<_DragAndDropLists> with AutomaticKeep _buildDragAndDropLists() { return Container( color: ConstantColor.greyBackground, - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: DragAndDropLists( children: List.generate( _bloc.list.length, (index) => _buildChildrenList(_bloc.list[index].father, _bloc.list[index].children)), onItemReorder: _onItemReorder, onListReorder: _onListReorder, - listPadding: const EdgeInsets.only(top: Constant.margin), + listPadding: EdgeInsets.only(top: Constant.margin), listGhost: Container( padding: const EdgeInsets.symmetric(vertical: 30.0, horizontal: 10.0), decoration: BoxDecoration( @@ -72,12 +72,12 @@ class _DragAndDropListsState extends State<_DragAndDropLists> with AutomaticKeep canDrag: _bloc.canEdit, initiallyExpanded: true, disableTopAndBottomBorders: true, - title: Text(father.name, style: const TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.body)), + title: Text(father.name, style: TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.body)), trailing: _actionButtons(() => _updateFather(father), () => _deleteFather(father)), children: List.generate(children.length, (index) => _buildChild(children[index])), listKey: ObjectKey(father), lastTarget: _buildAddButton(father), - contentsWhenEmpty: const SizedBox(height: 1), + contentsWhenEmpty: SizedBox(height: 1.sp), ); } @@ -85,7 +85,7 @@ class _DragAndDropListsState extends State<_DragAndDropLists> with AutomaticKeep if (!_bloc.canEdit) return null; return Center( child: TextButton( - child: const Row( + child: Row( mainAxisSize: MainAxisSize.min, children: [ Icon(ConstantIcon.add, size: ConstantFontSize.body, color: ConstantColor.greyText), diff --git a/lib/view/transaction/chart/transaction_chart.dart b/lib/view/transaction/chart/transaction_chart.dart index a439e02d..3b44e484 100644 --- a/lib/view/transaction/chart/transaction_chart.dart +++ b/lib/view/transaction/chart/transaction_chart.dart @@ -44,6 +44,7 @@ class _TransactionChartState extends State { child: Scaffold( backgroundColor: ConstantColor.greyBackground, appBar: AppBar( + titleSpacing: 0, title: const TabBar(tabs: [ Tab(child: Text('支出', softWrap: false, overflow: TextOverflow.clip)), Tab(child: Text('收入', softWrap: false, overflow: TextOverflow.clip)), @@ -169,7 +170,7 @@ class _ExpenseTabState extends State with AutomaticKeepAliveClientMi child: SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.margin, vertical: Constant.margin), + padding: EdgeInsets.symmetric(horizontal: Constant.margin, vertical: Constant.margin), child: _buildContant(), ), ), @@ -266,7 +267,7 @@ class _IncomeTabState extends State with AutomaticKeepAliveClientMixi child: SingleChildScrollView( physics: const AlwaysScrollableScrollPhysics(), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.margin, vertical: Constant.margin), + padding: EdgeInsets.symmetric(horizontal: Constant.margin, vertical: Constant.margin), child: _buildContent(), ), ), diff --git a/lib/view/transaction/chart/widget/category_amount_rank.dart b/lib/view/transaction/chart/widget/category_amount_rank.dart index 393d6cec..a580f7ba 100644 --- a/lib/view/transaction/chart/widget/category_amount_rank.dart +++ b/lib/view/transaction/chart/widget/category_amount_rank.dart @@ -57,11 +57,11 @@ class _CategoryAmountRankState extends State with SingleTick children: [ Text( '${data.name} (${data.amountProportiontoString()})', - style: const TextStyle(fontSize: ConstantFontSize.body), + style: TextStyle(fontSize: ConstantFontSize.body), ), Text.rich(AmountTextSpan.sameHeight( data.amount, - textStyle: const TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), + textStyle: TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), )) ], ), diff --git a/lib/view/transaction/chart/widget/category_pie_chart.dart b/lib/view/transaction/chart/widget/category_pie_chart.dart index c95a6d3e..e71f15c7 100644 --- a/lib/view/transaction/chart/widget/category_pie_chart.dart +++ b/lib/view/transaction/chart/widget/category_pie_chart.dart @@ -23,11 +23,11 @@ class _CategoryPieChartState extends State { int touchedIndex = 0; @override Widget build(BuildContext context) { - centerSpaceRadius = MediaQuery.of(context).size.width * 0.14; + centerSpaceRadius = MediaQuery.of(context).size.width * 0.14.sp; return Padding( padding: EdgeInsets.only(bottom: centerSpaceRadius * 0.62), child: SizedBox( - height: centerSpaceRadius * (1.3 + 1.61 * 0.61) * 2, + height: centerSpaceRadius * (1.3 + 1.61 * 0.61) * 2.sp, child: Stack( children: [ Positioned(child: Center(child: _buildSelected())), @@ -57,28 +57,28 @@ class _CategoryPieChartState extends State { CategoryRank get selected => rankList[touchedIndex]; Widget _buildSelected() { if (rankList.isEmpty) { - return const Text("无数据", style: TextStyle(letterSpacing: 4)); + return Text("无数据", style: TextStyle(letterSpacing: 4.sp)); } return DefaultTextStyle.merge( - style: const TextStyle(fontSize: ConstantFontSize.bodySmall), + style: TextStyle(fontSize: ConstantFontSize.bodySmall), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - Icon(selected.icon, size: 28), + Icon(selected.icon, size: Constant.iconlargeSize), Text( selected.name, - style: const TextStyle(fontSize: ConstantFontSize.body, letterSpacing: Constant.margin / 2), + style: TextStyle(fontSize: ConstantFontSize.body, letterSpacing: Constant.margin / 2), ), AmountText.sameHeight( selected.amount, unit: true, - textStyle: const TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), + textStyle: TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), ), Text( "${selected.count}笔", - style: const TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), + style: TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.w500), ), ], ), @@ -127,7 +127,7 @@ class _CategoryPieChartState extends State { value: rank.amountProportion / 100, title: rank.amountProportiontoString(), showTitle: isTouched, - titlePositionPercentageOffset: 1.55, + titlePositionPercentageOffset: 1.67, radius: isTouched ? centerSpaceRadius * 1.61 * 0.61 : centerSpaceRadius * 0.61, titleStyle: TextStyle( fontSize: isTouched ? ConstantFontSize.bodyLarge : ConstantFontSize.body, diff --git a/lib/view/transaction/chart/widget/enter.dart b/lib/view/transaction/chart/widget/enter.dart index 911feb1d..4ea847ee 100644 --- a/lib/view/transaction/chart/widget/enter.dart +++ b/lib/view/transaction/chart/widget/enter.dart @@ -1,5 +1,6 @@ import 'dart:math'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart' show DateFormat; import 'package:fl_chart/fl_chart.dart'; import 'package:flutter/material.dart'; diff --git a/lib/view/transaction/chart/widget/statistics_line_chart.dart b/lib/view/transaction/chart/widget/statistics_line_chart.dart index 75763d7e..0c7e9180 100644 --- a/lib/view/transaction/chart/widget/statistics_line_chart.dart +++ b/lib/view/transaction/chart/widget/statistics_line_chart.dart @@ -64,7 +64,7 @@ class _StatisticsLineChartState extends State { LineTooltipItem _buildToolcontent(LineBarSpot touchedSpot) { return LineTooltipItem( list[touchedSpot.x.toInt()].getDateByType() + '\n' + touchedSpot.y.toStringAsFixed(2), - const TextStyle( + TextStyle( color: ConstantColor.primaryColor, fontSize: ConstantFontSize.body, )); @@ -73,7 +73,7 @@ class _StatisticsLineChartState extends State { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: LineChart( LineChartData( lineTouchData: LineTouchData( @@ -129,7 +129,7 @@ class _StatisticsLineChartState extends State { } return Text( dateTitle[value.toInt()]!, - style: const TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.bodySmall), + style: TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.bodySmall), ); }, interval: 1, diff --git a/lib/view/transaction/chart/widget/total_header.dart b/lib/view/transaction/chart/widget/total_header.dart index e43a7974..3c3b56f5 100644 --- a/lib/view/transaction/chart/widget/total_header.dart +++ b/lib/view/transaction/chart/widget/total_header.dart @@ -10,14 +10,14 @@ class TotalHeader extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.padding), child: IntrinsicHeight( child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Expanded(child: _buildColumn(title: "总${type.label}", amount: amount)), - const VerticalDivider( + VerticalDivider( color: ConstantColor.greyText, width: Constant.padding, thickness: 1, @@ -43,7 +43,7 @@ class TotalHeader extends StatelessWidget { )), AmountText.sameHeight( amount, - textStyle: const TextStyle(fontSize: 24, color: ConstantColor.primaryColor, fontWeight: FontWeight.w500), + textStyle: TextStyle(fontSize: 24, color: ConstantColor.primaryColor, fontWeight: FontWeight.w500), dollarSign: true, ), ], diff --git a/lib/view/transaction/detail/transaction_detail_bottom_sheet.dart b/lib/view/transaction/detail/transaction_detail_bottom_sheet.dart index 64fcf599..2891cae9 100644 --- a/lib/view/transaction/detail/transaction_detail_bottom_sheet.dart +++ b/lib/view/transaction/detail/transaction_detail_bottom_sheet.dart @@ -24,6 +24,7 @@ class _TransactionDetailBottomSheetState extends State(context).add(TransactionDataFetch(widget.account, widget.transactionId!)); @@ -31,7 +32,6 @@ class _TransactionDetailBottomSheetState extends State(BorderSide(color: ConstantColor.primaryColor)), ), - child: const Text( + child: Text( "删除", style: TextStyle(letterSpacing: Constant.buttomLetterSpacing), ), @@ -161,7 +161,7 @@ class _TransactionDetailBottomSheetState extends State { Widget _buildCard() { return Container( decoration: ConstantDecoration.cardDecoration, - margin: const EdgeInsets.symmetric(horizontal: Constant.margin), - padding: const EdgeInsets.all(Constant.smallPadding), + margin: EdgeInsets.symmetric(horizontal: Constant.margin), + padding: EdgeInsets.all(Constant.smallPadding), child: Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.end, @@ -48,7 +48,7 @@ class _BottomState extends State { _buildButtonGroup(), AmountText.sameHeight( _bloc.transInfo.amount, - textStyle: const TextStyle(fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black), + textStyle: TextStyle(fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black), dollarSign: true, ), const Divider(), @@ -64,12 +64,12 @@ class _BottomState extends State { keyboradHistory, overflow: TextOverflow.ellipsis, maxLines: 2, - style: const TextStyle(fontSize: ConstantFontSize.bodySmall), + style: TextStyle(fontSize: ConstantFontSize.bodySmall), ), - const SizedBox(width: 2), + SizedBox(width: Constant.margin / 4), Text( keyboradInput, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), ) ], )) @@ -168,7 +168,7 @@ class _BottomState extends State { Widget _buildButton({required Function onPressed, required String name, IconData? icon}) { return Padding( - padding: const EdgeInsets.only(left: Constant.smallPadding), + padding: EdgeInsets.only(left: Constant.smallPadding), child: GestureDetector( onTap: () => onPressed(), child: Chip( @@ -194,7 +194,7 @@ class _BottomState extends State { ), Text( name, - style: const TextStyle(color: ConstantColor.primaryColor, fontSize: ConstantFontSize.bodySmall), + style: TextStyle(color: ConstantColor.primaryColor, fontSize: ConstantFontSize.bodySmall), ) ], ))), diff --git a/lib/view/transaction/edit/widget/category_picker.dart b/lib/view/transaction/edit/widget/category_picker.dart index 7843d346..d0d28912 100644 --- a/lib/view/transaction/edit/widget/category_picker.dart +++ b/lib/view/transaction/edit/widget/category_picker.dart @@ -65,7 +65,7 @@ class _CategoryPickerState extends State with AutomaticKeepAlive child: child, ); return Container( - padding: const EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), + padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), color: ConstantColor.greyBackground, child: child, ); @@ -76,7 +76,7 @@ class _CategoryPickerState extends State with AutomaticKeepAlive shrinkWrap: true, padding: EdgeInsets.zero, itemCount: categoryList.length, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, crossAxisSpacing: Constant.padding, mainAxisSpacing: Constant.padding, diff --git a/lib/view/transaction/flow/transaction_flow.dart b/lib/view/transaction/flow/transaction_flow.dart index 2b957c5c..084ae78d 100644 --- a/lib/view/transaction/flow/transaction_flow.dart +++ b/lib/view/transaction/flow/transaction_flow.dart @@ -115,7 +115,7 @@ class _TransactionFlowState extends State { }, ), body: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: RefreshIndicator( onRefresh: () async => _flowListBloc.add(FlowListDataFetchEvent(account: _conditionCubit.account)), child: NotificationListener( @@ -164,7 +164,7 @@ class _TransactionFlowState extends State { controller: _scrollController, slivers: [ SliverToBoxAdapter( - child: Padding(padding: const EdgeInsets.symmetric(vertical: Constant.padding), child: headerCard), + child: Padding(padding: EdgeInsets.symmetric(vertical: Constant.padding), child: headerCard), ), ...buildMonthStatisticGroupList() ], @@ -186,7 +186,10 @@ class _TransactionFlowState extends State { child: BlocBuilder( buildWhen: (_, state) => state is FlowCurrentAccountChanged, builder: (context, state) { - return Row(children: [Icon(_conditionCubit.account.icon, size: 18), Text(_conditionCubit.account.name)]); + return Row(children: [ + Icon(_conditionCubit.account.icon, size: Constant.iconSize), + Text(_conditionCubit.account.name) + ]); }, ), ), @@ -198,9 +201,10 @@ class _TransactionFlowState extends State { startDate: _conditionCubit.condition.startTime, endDate: _conditionCubit.condition.endTime, ).push(), - icon: const Icon( + icon: Icon( Icons.pie_chart_outline_outlined, color: ConstantColor.primaryColor, + size: Constant.iconSize, ), ), Builder(builder: (context) { @@ -264,9 +268,9 @@ class _TransactionFlowState extends State { widgetlist.addAll([_buildDateFunc(list[i], i == 0 ? null : list[i - 1]), _buildOneTransactionFunc(list[i])]); } return SliverPadding( - padding: const EdgeInsets.only(bottom: Constant.margin), + padding: EdgeInsets.only(bottom: Constant.margin), sliver: DecoratedSliver( - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( bottomLeft: Radius.circular(Constant.radius), @@ -306,7 +310,7 @@ class _TransactionFlowState extends State { subtitle: Text(subtitleStr), trailing: AmountText.sameHeight( model.amount, - textStyle: const TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.normal), + textStyle: TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.normal), incomeExpense: model.incomeExpense, displayModel: IncomeExpenseDisplayModel.symbols, ), @@ -319,7 +323,7 @@ class _TransactionFlowState extends State { return ConstantWidget.divider.indented; } else { return Padding( - padding: const EdgeInsets.only(left: Constant.padding, top: Constant.margin), + padding: EdgeInsets.only(left: Constant.padding, top: Constant.margin), child: Text( DateFormat("dd日").format(widget.account.getTZDateTime(currentTrans.tradeTime)), style: const TextStyle(fontWeight: FontWeight.w500), diff --git a/lib/view/transaction/flow/widget/condition_bottom_sheet.dart b/lib/view/transaction/flow/widget/condition_bottom_sheet.dart index c345ac50..139e484f 100644 --- a/lib/view/transaction/flow/widget/condition_bottom_sheet.dart +++ b/lib/view/transaction/flow/widget/condition_bottom_sheet.dart @@ -53,7 +53,7 @@ class _ConditionBottomSheetState extends State { builder: (context, state) { return Stack(children: [ Container( - padding: const EdgeInsets.only(top: Constant.buttomSheetRadius), + padding: EdgeInsets.only(top: Constant.buttomSheetRadius), decoration: ConstantDecoration.bottomSheet, height: size.height * 0.8, width: size.width, @@ -98,18 +98,18 @@ class _ConditionBottomSheetState extends State { Widget _buildOneConditon(List widgetList, {String? name}) { return Padding( - padding: const EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), + padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(bottom: Constant.padding), + padding: EdgeInsets.only(bottom: Constant.padding), child: Visibility( visible: name != null, child: Text( name ?? "", - style: const TextStyle(fontSize: ConstantFontSize.bodyLarge, fontWeight: FontWeight.w500), + style: TextStyle(fontSize: ConstantFontSize.bodyLarge, fontWeight: FontWeight.w500), ), ), ), @@ -135,7 +135,7 @@ class _ConditionBottomSheetState extends State { ), ), SizedBox( - width: 32, + width: 32.w, child: Divider( color: ConstantColor.greyText, indent: Constant.margin, @@ -182,19 +182,24 @@ class _ConditionBottomSheetState extends State { segments: [ ButtonSegment( value: IncomeExpense.income, - label: Text("收入", - style: TextStyle( - fontSize: ConstantFontSize.body, - color: selectedIncomeExpense == IncomeExpense.income ? Colors.white : null, - )), + label: Padding( + padding: EdgeInsets.symmetric(vertical: Constant.padding, horizontal: Constant.padding / 2), + child: Text("收入", + style: TextStyle( + fontSize: ConstantFontSize.body, + color: selectedIncomeExpense == IncomeExpense.income ? Colors.white : null, + )), + ), ), ButtonSegment( value: IncomeExpense.expense, - label: Text("支出", - style: TextStyle( - fontSize: ConstantFontSize.body, - color: selectedIncomeExpense == IncomeExpense.expense ? Colors.white : null, - )), + label: Padding( + padding: EdgeInsets.symmetric(vertical: Constant.padding, horizontal: Constant.padding / 2), + child: Text("支出", + style: TextStyle( + fontSize: ConstantFontSize.body, + color: selectedIncomeExpense == IncomeExpense.expense ? Colors.white : null, + ))), ) ], ), @@ -227,9 +232,11 @@ class _ConditionBottomSheetState extends State { physics: const NeverScrollableScrollPhysics(), padding: EdgeInsets.zero, shrinkWrap: true, - gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( + gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 5, - mainAxisSpacing: 1, + crossAxisSpacing: Constant.padding, + mainAxisSpacing: Constant.padding, + childAspectRatio: 0.8, ), itemCount: list.length, itemBuilder: (context, index) => _buildCategoryIcon(list[index]), diff --git a/lib/view/transaction/flow/widget/enter.dart b/lib/view/transaction/flow/widget/enter.dart index 9972bb7e..5ace270d 100644 --- a/lib/view/transaction/flow/widget/enter.dart +++ b/lib/view/transaction/flow/widget/enter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/common/model.dart'; diff --git a/lib/view/transaction/flow/widget/header_card.dart b/lib/view/transaction/flow/widget/header_card.dart index c9d722e1..c67b9aa7 100644 --- a/lib/view/transaction/flow/widget/header_card.dart +++ b/lib/view/transaction/flow/widget/header_card.dart @@ -21,8 +21,8 @@ class _HeaderCardState extends State { @override Widget build(BuildContext context) { return Container( - padding: const EdgeInsets.all(Constant.padding), - decoration: const BoxDecoration( + padding: EdgeInsets.all(Constant.padding), + decoration: BoxDecoration( color: ConstantColor.primaryColor, borderRadius: ConstantDecoration.borderRadius, ), @@ -38,17 +38,19 @@ class _HeaderCardState extends State { Row( children: [ Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Text.rich( - TextSpan(children: [ - AmountTextSpan.sameHeight( - totalData.income.amount - totalData.expense.amount, - dollarSign: true, - textStyle: const TextStyle(fontSize: 24, fontWeight: FontWeight.w500), - ), - const WidgetSpan(child: SizedBox(width: Constant.margin)), - const TextSpan(text: "结余", style: TextStyle(fontSize: ConstantFontSize.body)) - ]), + TextSpan( + children: [ + AmountTextSpan.sameHeight( + totalData.income.amount - totalData.expense.amount, + dollarSign: true, + textStyle: const TextStyle(fontSize: 26, fontWeight: FontWeight.w500), + ), + WidgetSpan(child: SizedBox(width: Constant.padding)), + TextSpan(text: "结余", style: TextStyle(fontSize: ConstantFontSize.body)) + ], + ), ), ) ], @@ -90,14 +92,14 @@ class _HeaderCardState extends State { } return GestureDetector( child: Container( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), decoration: BoxDecoration(borderRadius: BorderRadius.circular(32), color: ConstantColor.secondaryColor), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ - Text(dateText, style: const TextStyle(fontSize: ConstantFontSize.bodyLarge)), - const Icon(Icons.arrow_drop_down_outlined), + Text(dateText, style: TextStyle(fontSize: ConstantFontSize.bodyLarge)), + Icon(Icons.arrow_drop_down_outlined), ], ), ), @@ -117,10 +119,10 @@ class _HeaderCardState extends State { Widget _buildTotalData(String title, int amount) { return Text.rich( TextSpan( - style: const TextStyle(fontSize: ConstantFontSize.body), + style: TextStyle(fontSize: ConstantFontSize.body), children: [ TextSpan(text: title), - const WidgetSpan(child: SizedBox(width: Constant.margin)), + WidgetSpan(child: SizedBox(width: Constant.margin)), AmountTextSpan.sameHeight(amount) ], ), @@ -128,7 +130,7 @@ class _HeaderCardState extends State { } Widget _buildVerticalDivider() { - return const VerticalDivider( + return VerticalDivider( color: Colors.black, width: Constant.padding, thickness: 1, diff --git a/lib/view/transaction/flow/widget/month_statistic_header_delegate.dart b/lib/view/transaction/flow/widget/month_statistic_header_delegate.dart index c689640f..3dfe2c0c 100644 --- a/lib/view/transaction/flow/widget/month_statistic_header_delegate.dart +++ b/lib/view/transaction/flow/widget/month_statistic_header_delegate.dart @@ -3,7 +3,7 @@ part of 'enter.dart'; class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { MonthStatisticHeaderDelegate(this.data); - static TextStyle amountStyle = const TextStyle(color: Colors.black, fontSize: ConstantFontSize.headline); + static TextStyle amountStyle = TextStyle(color: Colors.black, fontSize: ConstantFontSize.headline); final double height = 56.5 + Constant.margin * 2; final InExStatisticWithTimeModel data; @@ -11,7 +11,7 @@ class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { return Container( height: height, - decoration: const BoxDecoration( + decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.only( topLeft: Radius.circular(Constant.radius), @@ -21,8 +21,7 @@ class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { child: Column( children: [ Padding( - padding: - const EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, Constant.padding), + padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, Constant.padding), child: BlocBuilder( builder: (context, state) { if (state is! FlowListLoading) { @@ -48,14 +47,14 @@ class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { children: [ Text.rich( TextSpan( - style: const TextStyle(fontWeight: FontWeight.w500), + style: TextStyle(fontWeight: FontWeight.w500), children: [ - TextSpan(text: DateFormat("MM").format(data.startTime), style: const TextStyle(fontSize: 24)), - const TextSpan(text: "月", style: TextStyle(fontSize: ConstantFontSize.body)), - const WidgetSpan(child: SizedBox(width: Constant.margin)), + TextSpan(text: DateFormat("MM").format(data.startTime), style: TextStyle(fontSize: 24)), + TextSpan(text: "月", style: TextStyle(fontSize: ConstantFontSize.body)), + WidgetSpan(child: SizedBox(width: Constant.margin)), TextSpan( text: DateFormat("yyyy").format(data.startTime), - style: const TextStyle( + style: TextStyle( fontSize: ConstantFontSize.bodySmall, fontWeight: FontWeight.normal, ), @@ -75,7 +74,7 @@ class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { _buildItem("支", data.expense.amount, ConstantColor.expenseAmount), ], ), - const SizedBox(width: Constant.padding), + SizedBox(width: Constant.padding), Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ @@ -96,9 +95,9 @@ class MonthStatisticHeaderDelegate extends SliverPersistentHeaderDelegate { children: [ Text( text, - style: const TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.bodySmall), + style: TextStyle(color: ConstantColor.greyText, fontSize: ConstantFontSize.bodySmall), ), - const SizedBox(width: Constant.margin / 2), + SizedBox(width: Constant.margin / 2), AmountText.sameHeight( amount, textStyle: TextStyle(color: amountColor, fontSize: ConstantFontSize.body), diff --git a/lib/view/transaction/import/transaction_import.dart b/lib/view/transaction/import/transaction_import.dart index 93c41b7c..c54387c1 100644 --- a/lib/view/transaction/import/transaction_import.dart +++ b/lib/view/transaction/import/transaction_import.dart @@ -70,7 +70,7 @@ class _TransactionImportState extends State { return DecoratedBox( decoration: BoxDecoration(color: ConstantColor.greyBackground), child: Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: ExecCard(product: state.list[index], categoryTree: state.tree), ), ); @@ -85,9 +85,9 @@ class _Func { static Card _buildCard({required Widget child}) { return Card( color: Colors.white, - margin: const EdgeInsets.all(Constant.margin), + margin: EdgeInsets.all(Constant.margin), elevation: 0, - shape: const RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: ConstantDecoration.borderRadius, ), child: child, diff --git a/lib/view/transaction/import/widget/exec_card.dart b/lib/view/transaction/import/widget/exec_card.dart index 6e347859..cc2d8d7c 100644 --- a/lib/view/transaction/import/widget/exec_card.dart +++ b/lib/view/transaction/import/widget/exec_card.dart @@ -100,14 +100,14 @@ class _ExecCardState extends State { header.add(Text("忽略${_cubit.ignoreCount}笔")); } return Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ if (header.length > 0) Padding( - padding: const EdgeInsets.only(bottom: Constant.margin), + padding: EdgeInsets.only(bottom: Constant.margin), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: header, diff --git a/lib/view/transaction/import/widget/fail_dialog.dart b/lib/view/transaction/import/widget/fail_dialog.dart index 36140a9e..4f78bca2 100644 --- a/lib/view/transaction/import/widget/fail_dialog.dart +++ b/lib/view/transaction/import/widget/fail_dialog.dart @@ -67,16 +67,16 @@ class _FailDialogState extends State { final trans = _cubit.currentFailTrans!; final tip = _cubit.currentFailTip; return Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Column( mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: const EdgeInsets.only(bottom: Constant.margin), + padding: EdgeInsets.only(bottom: Constant.margin), child: LargeCategoryIconAndName(trans.categoryBaseModel), ), Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: AmountText.sameHeight( trans.amount, textStyle: TextStyle(fontSize: 24, fontWeight: FontWeight.w500), @@ -85,7 +85,7 @@ class _FailDialogState extends State { _buildInfoWidget(labal: "备注", content: trans.remark.isEmpty ? "无" : trans.remark), if (tip != null) Padding( - padding: const EdgeInsets.only(top: Constant.margin), + padding: EdgeInsets.only(top: Constant.margin), child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ diff --git a/lib/view/transaction/import/widget/ptc_card.dart b/lib/view/transaction/import/widget/ptc_card.dart index ee0ecab9..17fa367c 100644 --- a/lib/view/transaction/import/widget/ptc_card.dart +++ b/lib/view/transaction/import/widget/ptc_card.dart @@ -33,7 +33,7 @@ class PtcCard extends StatelessWidget { return SizedBox(); } return Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Offstage( offstage: ptcList.length == 0 || false == @@ -53,7 +53,7 @@ class PtcCard extends StatelessWidget { ptcList: ptcList, ).push(); }, - child: const Text('设置交易类型关联', style: TextStyle(fontSize: ConstantFontSize.headline))), + child: Text('设置交易类型关联', style: TextStyle(fontSize: ConstantFontSize.headline))), ), ); }, @@ -65,7 +65,7 @@ class PtcCard extends StatelessWidget { Widget buildItem(ProductTransactionCategoryModel model) { return Chip( elevation: 0, - label: Text(model.name, style: const TextStyle(fontSize: ConstantFontSize.bodySmall)), + label: Text(model.name, style: TextStyle(fontSize: ConstantFontSize.bodySmall)), padding: EdgeInsets.zero, backgroundColor: Colors.white, side: BorderSide.none, diff --git a/lib/view/transaction/share/transaction_share_bottom_sheet.dart b/lib/view/transaction/share/transaction_share_bottom_sheet.dart index 24793f6b..7b4a2e14 100644 --- a/lib/view/transaction/share/transaction_share_bottom_sheet.dart +++ b/lib/view/transaction/share/transaction_share_bottom_sheet.dart @@ -4,6 +4,7 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/common/global.dart' show Constant, ConstantColor, ConstantDecoration, ConstantFontSize; @@ -32,14 +33,14 @@ class TransactionShareDialog extends StatelessWidget { GestureDetector( onTap: () => _onSaveImage(), child: Container( - margin: const EdgeInsets.only(top: Constant.padding), + margin: EdgeInsets.only(top: Constant.padding), decoration: BoxDecoration( color: ConstantColor.greyButton, borderRadius: BorderRadius.circular(90), ), - width: 48, - height: 48, - child: const Icon(Icons.download_outlined, size: 28), + width: 48.sp, + height: 48.sp, + child: Icon(Icons.download_outlined, size: 28), )), ], ), @@ -89,7 +90,7 @@ class TransactionShareDialog extends StatelessWidget { child: AspectRatio( aspectRatio: 0.6, child: DecoratedBox( - decoration: const BoxDecoration( + decoration: BoxDecoration( borderRadius: ConstantDecoration.borderRadius, color: Colors.white, image: DecorationImage( @@ -122,12 +123,12 @@ class TransactionShareDialog extends StatelessWidget { height: 48, child: Icon(icon, size: 28), ), - const SizedBox( + SizedBox( height: Constant.margin, ), Text( name, - style: const TextStyle(fontSize: ConstantFontSize.headline), + style: TextStyle(fontSize: ConstantFontSize.headline), ), ], ); @@ -135,20 +136,20 @@ class TransactionShareDialog extends StatelessWidget { Widget _buildAmount() { return Padding( - padding: const EdgeInsets.only(top: Constant.smallPadding, bottom: Constant.padding), + padding: EdgeInsets.only(top: Constant.smallPadding, bottom: Constant.padding), child: Text.rich( AmountTextSpan.sameHeight( data.amount, incomeExpense: data.incomeExpense, displayModel: IncomeExpenseDisplayModel.symbols, - textStyle: const TextStyle(fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black), + textStyle: TextStyle(fontSize: 24, fontWeight: FontWeight.w500, color: Colors.black), ), ), ); } optionWidget _buildDetail(String title, String value) { - return optionWidget(title: Text(title, style: const TextStyle(color: Colors.black54)), value: Text(value)); + return optionWidget(title: Text(title, style: TextStyle(color: Colors.black54)), value: Text(value)); } Future _getImageData() async { diff --git a/lib/view/transaction/timing/cubit/transaction_timing_cubit.dart b/lib/view/transaction/timing/cubit/transaction_timing_cubit.dart index 401c7984..e6c5d92a 100644 --- a/lib/view/transaction/timing/cubit/transaction_timing_cubit.dart +++ b/lib/view/transaction/timing/cubit/transaction_timing_cubit.dart @@ -23,18 +23,29 @@ class TransactionTimingCubit extends Cubit { /* list operation */ List<({TransactionTimingModel config, TransactionInfoModel trans})> list = []; - int _offset = 0, _limit = 20; + int _offset = 0, _limit = 10; Future> loadList() async { _offset = 0; - _limit = 20; - list = await TransactionApi.getTimingList(accountId: account.id, offset: _offset, limit: _limit); + list = await TransactionApi.getTimingList(accountId: account.id, offset: 0, limit: _limit); + if (_limit != list.length) { + noMore = true; + } else { + noMore = false; + _offset == list.length; + } emit(TransactionTimingListLoaded()); return list; } + bool noMore = false; Future> loadMore() async { - _offset += _limit; - list.addAll(await TransactionApi.getTimingList(accountId: account.id, offset: _offset, limit: _limit)); + list.addAll(await TransactionApi.getTimingList(accountId: account.id, offset: list.length, limit: _limit)); + if (_offset == list.length) { + noMore = true; + } else { + noMore = false; + _offset == list.length; + } emit(TransactionTimingListLoaded()); return list; } @@ -48,13 +59,6 @@ class TransactionTimingCubit extends Cubit { } } - _updateListElementConfig(TransactionTimingModel config) { - var index = list.indexWhere((element) => element.config.id == config.id); - if (index >= 0) { - list[index] = (trans: list[index].trans, config: config); - } - } - /* single operation */ TransactionInfoModel trans = TransactionInfoModel.prototypeData(); TransactionTimingModel config = TransactionTimingModel.prototypeData(); diff --git a/lib/view/transaction/timing/list/transaction_timing_list.dart b/lib/view/transaction/timing/list/transaction_timing_list.dart index d6126469..d396b28d 100644 --- a/lib/view/transaction/timing/list/transaction_timing_list.dart +++ b/lib/view/transaction/timing/list/transaction_timing_list.dart @@ -17,19 +17,28 @@ class TransactionTimingList extends StatefulWidget { class _TransactionTimingListState extends State { late final TransactionTimingCubit _cubit; - + final ScrollController _scrollController = ScrollController(); @override void initState() { - _cubit = TransactionTimingCubit(account: widget.account)..loadList(); super.initState(); + _cubit = TransactionTimingCubit(account: widget.account)..loadList(); + _scrollController.addListener(_scrollListener); } @override void dispose() { _cubit.close(); + _scrollController.removeListener(_scrollListener); + _scrollController.dispose(); super.dispose(); } + void _scrollListener() { + if (_scrollController.position.pixels == _scrollController.position.maxScrollExtent) { + _cubit.loadMore(); + } + } + @override Widget build(BuildContext context) { return BlocProvider.value( @@ -46,17 +55,23 @@ class _TransactionTimingListState extends State { ), backgroundColor: ConstantColor.greyBackground, body: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding, vertical: Constant.margin), child: BlocBuilder( buildWhen: (context, state) => state is TransactionTimingListLoaded, builder: (context, state) { if (state is TransactionTimingListLoaded && _cubit.list.isNotEmpty) { - return ListView.builder( - itemCount: _cubit.list.length, - itemBuilder: (context, index) => _buildListOne(_cubit.list[index]), - ); + return RefreshIndicator( + onRefresh: () async => _cubit.loadList(), + child: ListView.builder( + controller: _scrollController, + itemCount: _cubit.list.length + 1, + itemBuilder: (context, index) => + index == _cubit.list.length ? _buildLoadingIndicator() : _buildListOne(_cubit.list[index]), + )); } else { - return SizedBox(height: 64, child: Center(child: NoData.commonWidget)); + return ListView( + children: [SizedBox(height: 64, child: Center(child: NoData.commonWidget))], + ); } }, ), @@ -75,7 +90,7 @@ class _TransactionTimingListState extends State { Widget _buildListOne(({TransactionInfoModel trans, TransactionTimingModel config}) record) { return Padding( - padding: const EdgeInsets.only(top: Constant.margin), + padding: EdgeInsets.only(top: Constant.margin), child: Slidable( key: Key("trans_config_slidable:" + record.config.id.toString()), endActionPane: ActionPane( @@ -126,4 +141,13 @@ class _TransactionTimingListState extends State { label: name, ); } + + Widget _buildLoadingIndicator() { + return Padding( + padding: EdgeInsets.all(Constant.margin), + child: Center( + child: _cubit.noMore ? Text('没有更多数据了') : CircularProgressIndicator(), + ), + ); + } } diff --git a/lib/view/transaction/timing/transaction_timing.dart b/lib/view/transaction/timing/transaction_timing.dart index 068bf840..3fc51c94 100644 --- a/lib/view/transaction/timing/transaction_timing.dart +++ b/lib/view/transaction/timing/transaction_timing.dart @@ -57,13 +57,13 @@ class _TransactionTimingState extends State { ), backgroundColor: ConstantColor.greyBackground, body: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: Column( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.padding), child: BlocBuilder( buildWhen: (previous, current) => current is TransactionTimingTransChanged, builder: (context, state) { @@ -97,11 +97,11 @@ class _TransactionTimingState extends State { mainAxisSize: MainAxisSize.max, children: [ Padding( - padding: const EdgeInsets.only(bottom: Constant.padding), + padding: EdgeInsets.only(bottom: Constant.padding), child: DecoratedBox(decoration: ConstantDecoration.cardDecoration, child: FromField()), ), Padding( - padding: const EdgeInsets.only(bottom: Constant.padding), + padding: EdgeInsets.only(bottom: Constant.padding), child: DecoratedBox( decoration: ConstantDecoration.cardDecoration, child: SaveButtom(), diff --git a/lib/view/transaction/timing/widget/bottom_select.dart b/lib/view/transaction/timing/widget/bottom_select.dart index 488889f3..7a67aa8a 100644 --- a/lib/view/transaction/timing/widget/bottom_select.dart +++ b/lib/view/transaction/timing/widget/bottom_select.dart @@ -67,7 +67,7 @@ class _TimingBottomSelecterState extends State { options: TransactionTimingType.selectOptions, backgroundColor: Colors.transparent, selected: _config.type, - height: _height, + height: _height.h, onTap: onTapType, ), ), @@ -80,7 +80,7 @@ class _TimingBottomSelecterState extends State { selected: _config.nextTime, mode: DateSelectMode.week, type: BottomCupertinoSelecter, - height: _height), + height: _height.h), ), AnimatedContainer( duration: _animatedDuration, @@ -91,7 +91,7 @@ class _TimingBottomSelecterState extends State { selected: _config.nextTime, mode: DateSelectMode.month, type: BottomCupertinoSelecter, - height: _height), + height: _height.h), ) ]); } diff --git a/lib/view/transaction/timing/widget/enter.dart b/lib/view/transaction/timing/widget/enter.dart index 6e95f5f7..9da617c2 100644 --- a/lib/view/transaction/timing/widget/enter.dart +++ b/lib/view/transaction/timing/widget/enter.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/transaction/model.dart'; import 'package:leap_ledger_app/view/transaction/timing/cubit/transaction_timing_cubit.dart'; diff --git a/lib/view/user/account/invitation/user_acount_invitation.dart b/lib/view/user/account/invitation/user_acount_invitation.dart index 579dbb1f..84e7003e 100644 --- a/lib/view/user/account/invitation/user_acount_invitation.dart +++ b/lib/view/user/account/invitation/user_acount_invitation.dart @@ -64,7 +64,7 @@ class _UserAccountInvitationState extends State { Widget _buildListTile(AccountUserInvitationModle invitation) { return ListTile( - leading: Icon(invitation.account.icon, size: 32, color: ConstantColor.primaryColor), + leading: Icon(invitation.account.icon, size: Constant.iconlargeSize, color: ConstantColor.primaryColor), title: Text(invitation.account.name), subtitle: Text( "来自${invitation.inviter.username}的邀请", @@ -88,14 +88,14 @@ class _UserAccountInvitationState extends State { default: return Text( invitation.status.name, - style: const TextStyle(fontSize: ConstantFontSize.largeHeadline, color: ConstantColor.greyText), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline, color: ConstantColor.greyText), ); } } Widget _buildButton(String text, VoidCallback onTap) { return Padding( - padding: const EdgeInsets.only(left: Constant.margin), + padding: EdgeInsets.only(left: Constant.margin), child: GestureDetector( onTap: onTap, child: DecoratedBox( @@ -107,7 +107,7 @@ class _UserAccountInvitationState extends State { padding: const EdgeInsets.symmetric(vertical: 4, horizontal: 12), child: Text( text, - style: const TextStyle(color: Colors.black, fontSize: ConstantFontSize.body), + style: TextStyle(color: Colors.black, fontSize: ConstantFontSize.body), ), ), ), diff --git a/lib/view/user/config/transaction/share/user_config_transaction_share.dart b/lib/view/user/config/transaction/share/user_config_transaction_share.dart index 2b88f84b..51624ae6 100644 --- a/lib/view/user/config/transaction/share/user_config_transaction_share.dart +++ b/lib/view/user/config/transaction/share/user_config_transaction_share.dart @@ -97,11 +97,11 @@ class _UserConfigTransactionShareState extends State Widget _buildStatusSwitch({required String name, required bool value, Function(bool)? onChanged}) { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin), + padding: EdgeInsets.symmetric(vertical: Constant.margin), child: DecoratedBox( decoration: const BoxDecoration(color: Colors.white), child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, diff --git a/lib/view/user/forgetPassword/user_forgetPassword.dart b/lib/view/user/forgetPassword/user_forgetPassword.dart index b444eb05..ff81c165 100644 --- a/lib/view/user/forgetPassword/user_forgetPassword.dart +++ b/lib/view/user/forgetPassword/user_forgetPassword.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/widget/common/common.dart'; @@ -44,7 +45,7 @@ class UserForgetPasswordState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 80), + SizedBox(height: 80.h), const Padding( padding: EdgeInsets.all(10), child: Text( @@ -66,9 +67,7 @@ class UserForgetPasswordState extends State { controller: pwdController, obscureText: true, ), - const SizedBox( - height: 70, - ), + SizedBox(height: 70.h), buildSubmitButton(), ], ), @@ -81,8 +80,8 @@ class UserForgetPasswordState extends State { Widget buildSubmitButton() { return Align( child: SizedBox( - height: 45, - width: 270, + height: 45.h, + width: 270.w, child: ElevatedButton( style: ButtonStyle( shape: WidgetStateProperty.all(const StadiumBorder(side: BorderSide(style: BorderStyle.none)))), diff --git a/lib/view/user/login/user_login.dart b/lib/view/user/login/user_login.dart index 8660dd19..7643d4e0 100644 --- a/lib/view/user/login/user_login.dart +++ b/lib/view/user/login/user_login.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/current.dart'; import 'package:leap_ledger_app/common/global.dart'; @@ -61,18 +62,18 @@ class UserLoginState extends State { } }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 80), - const Padding( + SizedBox(height: 80.h), + Padding( padding: EdgeInsets.all(Constant.margin), child: Text("登录", style: TextStyle(fontWeight: FontWeight.w500, fontSize: 42)), ), - const SizedBox(height: 20), + SizedBox(height: 20.h), TextField(decoration: const InputDecoration(labelText: '邮箱'), controller: emailController), - const SizedBox(height: 20), + SizedBox(height: 20.h), TextField( decoration: const InputDecoration(labelText: '密码'), controller: pwdController, @@ -91,9 +92,9 @@ class UserLoginState extends State { child: const Text("忘记密码")) ], ), - const SizedBox(height: 40), - Padding(padding: const EdgeInsets.all(Constant.padding), child: _buildTourButton()), - const SizedBox(height: 30), + SizedBox(height: 40.h), + Padding(padding: EdgeInsets.all(Constant.padding), child: _buildTourButton()), + SizedBox(height: 30.h), buildLoginButton(), ], ), @@ -108,8 +109,8 @@ class UserLoginState extends State { Widget buildLoginButton() { return Align( child: SizedBox( - height: 45, - width: 270, + height: 45.h, + width: 270.w, child: ElevatedButton( style: ButtonStyle( shape: WidgetStateProperty.all(const StadiumBorder(side: BorderSide(style: BorderStyle.none)))), diff --git a/lib/view/user/password/update/user_password_update.dart b/lib/view/user/password/update/user_password_update.dart index 0a3e9d7e..0b7b5021 100644 --- a/lib/view/user/password/update/user_password_update.dart +++ b/lib/view/user/password/update/user_password_update.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/widget/common/common.dart'; @@ -59,9 +60,7 @@ class UserPasswordUpdateState extends State { controller: pwdController, obscureText: true, ), - const SizedBox( - height: 70, - ), + SizedBox(height: 70.h), buildSubmitButton(), ], ), @@ -74,8 +73,8 @@ class UserPasswordUpdateState extends State { Widget buildSubmitButton() { return Align( child: SizedBox( - height: 45, - width: 270, + height: 45.h, + width: 270.w, child: ElevatedButton( style: ButtonStyle( shape: WidgetStateProperty.all(const StadiumBorder(side: BorderSide(style: BorderStyle.none)))), diff --git a/lib/view/user/register/user_register.dart b/lib/view/user/register/user_register.dart index 7098d618..f5249958 100644 --- a/lib/view/user/register/user_register.dart +++ b/lib/view/user/register/user_register.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/bloc/user/user_bloc.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/routes/routes.dart'; @@ -46,12 +47,12 @@ class UserRegisterState extends State { } }, child: Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 80), - const Padding( + SizedBox(height: 80.h), + Padding( padding: EdgeInsets.all(Constant.margin), child: Text( "注册", @@ -78,9 +79,7 @@ class UserRegisterState extends State { UserAction.register, formKey: emailCaptchaKey, ), - const SizedBox( - height: 70, - ), + SizedBox(height: 70.h), buildSubmitButton(), ], ), @@ -93,8 +92,8 @@ class UserRegisterState extends State { Widget buildSubmitButton() { return Align( child: SizedBox( - height: 45, - width: 270, + height: 45.h, + width: 270.w, child: ElevatedButton( style: ButtonStyle( shape: WidgetStateProperty.all(const StadiumBorder(side: BorderSide(style: BorderStyle.none)))), diff --git a/lib/view/user/search/user_search.dart b/lib/view/user/search/user_search.dart index 703b99c7..85c06967 100644 --- a/lib/view/user/search/user_search.dart +++ b/lib/view/user/search/user_search.dart @@ -62,7 +62,7 @@ class _UserSearchState extends State { return Scaffold( appBar: AppBar( title: DefaultTextStyle.merge( - style: const TextStyle(fontSize: ConstantFontSize.largeHeadline), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline), child: FormInputField.searchInput( onChanged: (String? value) { _changeInputStr(value); diff --git a/lib/widget/amount/amount_input.dart b/lib/widget/amount/amount_input.dart index bb6da7e4..8434dfba 100644 --- a/lib/widget/amount/amount_input.dart +++ b/lib/widget/amount/amount_input.dart @@ -1,7 +1,7 @@ part of 'enter.dart'; class AmountInput extends StatelessWidget { - static const InputDecoration defaultDecoration = InputDecoration( + static InputDecoration defaultDecoration = InputDecoration( contentPadding: EdgeInsets.all(Constant.padding), prefixText: "¥", labelStyle: TextStyle(fontSize: ConstantFontSize.body), @@ -10,25 +10,27 @@ class AmountInput extends StatelessWidget { ); final Function(int?)? onSave; final Function(int?)? onChanged; - final InputDecoration decoration; + late final InputDecoration decoration; final int? initialValue; final TextEditingController? controller; - const AmountInput({ + AmountInput({ super.key, this.onSave, this.onChanged, this.initialValue, - this.decoration = defaultDecoration, + InputDecoration? decoration, this.controller, - }); + }) { + this.decoration = decoration ?? defaultDecoration; + } @override Widget build(BuildContext context) { return SizedBox( - height: 48, + height: 48.sp, child: TextFormField( controller: controller, - style: const TextStyle(fontSize: 14), + style: const TextStyle(fontSize: ConstantFontSize.body), keyboardType: const TextInputType.numberWithOptions(decimal: true), initialValue: initialValue != null ? (initialValue! / 100).toStringAsFixed(2) : null, showCursor: true, diff --git a/lib/widget/amount/amount_keyboard.dart b/lib/widget/amount/amount_keyboard.dart index cecad10f..6a23b96a 100644 --- a/lib/widget/amount/amount_keyboard.dart +++ b/lib/widget/amount/amount_keyboard.dart @@ -37,7 +37,7 @@ class _AmountKeyboardState extends State { @override Widget build(BuildContext context) { return Container( - margin: const EdgeInsets.symmetric(horizontal: Constant.margin / 2, vertical: Constant.margin / 2), + margin: EdgeInsets.symmetric(horizontal: Constant.margin / 2, vertical: Constant.margin / 2), width: MediaQuery.sizeOf(context).width, color: ConstantColor.greyBackground, child: Row( @@ -98,10 +98,9 @@ class _AmountKeyboardState extends State { return AspectRatio( aspectRatio: 1.6, child: Container( - margin: const EdgeInsets.all(Constant.margin / 2), + margin: EdgeInsets.all(Constant.margin / 2), decoration: BoxDecoration(borderRadius: BorderRadius.circular(Constant.radius), color: backgroundColor), child: Ink( - height: 50, decoration: BoxDecoration(borderRadius: BorderRadius.circular(Constant.radius)), child: Material( color: Colors.transparent, @@ -110,9 +109,7 @@ class _AmountKeyboardState extends State { onTap: () { onTap(); }, - child: Center( - child: name, - )), + child: Center(child: name)), )), ), ); @@ -260,8 +257,8 @@ class _TextAmountKeyboardState extends State { crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( - padding: const EdgeInsets.all(Constant.margin), - margin: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), + margin: EdgeInsets.all(Constant.margin), alignment: Alignment.centerRight, child: Column(crossAxisAlignment: CrossAxisAlignment.end, children: [ AmountText.sameHeight( @@ -281,12 +278,12 @@ class _TextAmountKeyboardState extends State { history, overflow: TextOverflow.ellipsis, maxLines: 2, - style: const TextStyle(fontSize: ConstantFontSize.bodySmall), + style: TextStyle(fontSize: ConstantFontSize.bodySmall), ), const SizedBox(width: 2), Text( input, - style: const TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), + style: TextStyle(fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline), ) ], )) diff --git a/lib/widget/amount/enter.dart b/lib/widget/amount/enter.dart index 8f97038a..40214160 100644 --- a/lib/widget/amount/enter.dart +++ b/lib/widget/amount/enter.dart @@ -1,6 +1,7 @@ import 'package:auto_size_text/auto_size_text.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/util/enter.dart'; diff --git a/lib/widget/amount/unequal_height_amount_text_span.dart b/lib/widget/amount/unequal_height_amount_text_span.dart index a57c5bc8..f6ef4cb8 100644 --- a/lib/widget/amount/unequal_height_amount_text_span.dart +++ b/lib/widget/amount/unequal_height_amount_text_span.dart @@ -22,9 +22,8 @@ class UnequalHeightAmountTextSpan extends StatelessWidget { String formattedAmount = amountInDollars.toStringAsFixed(2); List parts = formattedAmount.split('.'); double? tailFontSize = tailReduction ? textStyle.fontSize! * 2 / 3 : textStyle.fontSize; - return RichText( - textScaler: MediaQuery.of(context).textScaler, - text: TextSpan( + return Text.rich( + TextSpan( children: [ if (title != null) TextSpan( diff --git a/lib/widget/category/category_icon_and_name.dart b/lib/widget/category/category_icon_and_name.dart index 17af0fd8..23722866 100644 --- a/lib/widget/category/category_icon_and_name.dart +++ b/lib/widget/category/category_icon_and_name.dart @@ -20,13 +20,9 @@ class CategoryIconAndName extends Statel borderRadius: BorderRadius.circular(90), ), child: SizedBox( - width: 48, - height: 48, - child: Icon( - category.icon, - size: 28, - color: isSelected ? Colors.white : Colors.black, - ), + width: 48.sp, + height: 48.sp, + child: Icon(category.icon, size: 28, color: isSelected ? Colors.white : Colors.black), ), ), if (category.name.isNotEmpty) SizedBox(height: Constant.margin / 2), @@ -63,8 +59,8 @@ class LargeCategoryIconAndName extends StatelessWidget { DecoratedBox( decoration: BoxDecoration(color: ConstantColor.primaryColor, borderRadius: BorderRadius.circular(90)), child: SizedBox( - width: 48, - height: 48, + width: 48.sp, + height: 48.sp, child: Icon(category.icon, size: 28, color: Colors.white), ), ), diff --git a/lib/widget/category/enter.dart b/lib/widget/category/enter.dart index 05330ee3..23a86ab1 100644 --- a/lib/widget/category/enter.dart +++ b/lib/widget/category/enter.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/common/model.dart'; diff --git a/lib/widget/common/common.dart b/lib/widget/common/common.dart index f66f3175..21061ef3 100644 --- a/lib/widget/common/common.dart +++ b/lib/widget/common/common.dart @@ -4,6 +4,7 @@ import 'dart:math'; import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:fluttertoast/fluttertoast.dart'; import 'package:intl/intl.dart' show DateFormat; import 'package:leap_ledger_app/bloc/captcha/captcha_bloc.dart'; diff --git a/lib/widget/common/common_captcha.dart b/lib/widget/common/common_captcha.dart index 7118517e..ea5a0116 100644 --- a/lib/widget/common/common_captcha.dart +++ b/lib/widget/common/common_captcha.dart @@ -66,8 +66,8 @@ class CaptchaPic extends StatelessWidget { Image.memory( base64Decode(state.picBase64), fit: BoxFit.cover, - width: 180, - height: 50, + width: 180.w, + height: 50.sp, ), CaptchaButton(0) ], @@ -78,8 +78,8 @@ class CaptchaPic extends StatelessWidget { children: [ Container( color: Colors.grey, - width: 180, - height: 50, + width: 180.w, + height: 50.sp, ), CaptchaButton(0) ], diff --git a/lib/widget/common/common_card.dart b/lib/widget/common/common_card.dart index d968386d..58cffb8b 100644 --- a/lib/widget/common/common_card.dart +++ b/lib/widget/common/common_card.dart @@ -28,10 +28,10 @@ class CommonCard extends Card { ? [child] : [ Padding( - padding: const EdgeInsets.only(top: Constant.padding, left: Constant.padding), + padding: EdgeInsets.only(top: Constant.padding, left: Constant.padding), child: Text( title, - style: const TextStyle( + style: TextStyle( fontWeight: FontWeight.w500, fontSize: ConstantFontSize.headline, letterSpacing: 2, @@ -49,9 +49,9 @@ class CommonCard extends Card { } return CommonCard( color: background ?? Colors.white, - margin: const EdgeInsets.all(Constant.margin), + margin: EdgeInsets.all(Constant.margin), elevation: 0, - shape: const RoundedRectangleBorder( + shape: RoundedRectangleBorder( borderRadius: ConstantDecoration.borderRadius, ), child: child, diff --git a/lib/widget/common/common_email_captcha.dart b/lib/widget/common/common_email_captcha.dart index 78f57f00..bc805ec8 100644 --- a/lib/widget/common/common_email_captcha.dart +++ b/lib/widget/common/common_email_captcha.dart @@ -60,33 +60,26 @@ class CommonEmailCaptchaFormState extends State { child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - const SizedBox(height: 10), - CommonCaptcha( - key: captchaKey, - ), + SizedBox(height: Constant.margin), + CommonCaptcha(key: captchaKey), Visibility( visible: emailTextVisibility(), child: TextField( - decoration: const InputDecoration( - labelText: '邮箱', - ), + decoration: const InputDecoration(labelText: '邮箱'), controller: emailController, )), Row( crossAxisAlignment: CrossAxisAlignment.center, children: [ SizedBox( - width: 200, + width: 180.w, child: TextField( - decoration: const InputDecoration( - labelText: '邮箱验证码', - ), + maxLength: 6, + decoration: const InputDecoration(labelText: '邮箱验证码'), controller: emailCaptchaController, ), ), - const SizedBox( - width: 10, - ), + SizedBox(width: Constant.margin), buildSendButton(), ], ), diff --git a/lib/widget/common/common_expansion_list.dart b/lib/widget/common/common_expansion_list.dart index 7bac8386..d44ab2bd 100644 --- a/lib/widget/common/common_expansion_list.dart +++ b/lib/widget/common/common_expansion_list.dart @@ -45,12 +45,12 @@ class _CommonExpansionListState extends State with SingleTi _buildBottomContent() { late List list; if (!stateOfExpansion) { - list = const [ + list = [ Icon(Icons.keyboard_double_arrow_down_outlined, size: ConstantFontSize.body + 2), Text("展开", style: TextStyle(fontSize: ConstantFontSize.body)), ]; } else { - list = const [ + list = [ Icon(Icons.keyboard_double_arrow_up_outlined, size: ConstantFontSize.body + 2), Text("合起", style: TextStyle(fontSize: ConstantFontSize.body)), ]; diff --git a/lib/widget/common/common_lable.dart b/lib/widget/common/common_lable.dart index b7834ec6..49d391b5 100644 --- a/lib/widget/common/common_lable.dart +++ b/lib/widget/common/common_lable.dart @@ -6,15 +6,15 @@ class CommonLabel extends StatelessWidget { @override Widget build(BuildContext context) { return DecoratedBox( - decoration: const BoxDecoration( + decoration: BoxDecoration( borderRadius: ConstantDecoration.borderRadius, color: ConstantColor.secondaryColor, ), child: Padding( - padding: const EdgeInsets.symmetric(vertical: 0, horizontal: Constant.smallPadding), + padding: EdgeInsets.symmetric(vertical: 0, horizontal: Constant.smallPadding), child: Text( text, - style: const TextStyle(fontSize: ConstantFontSize.bodySmall, height: 1.7), + style: TextStyle(fontSize: ConstantFontSize.bodySmall, height: 1.7), textAlign: TextAlign.center, ), ), diff --git a/lib/widget/common/common_list_tile.dart b/lib/widget/common/common_list_tile.dart index 637753d9..92165a6d 100644 --- a/lib/widget/common/common_list_tile.dart +++ b/lib/widget/common/common_list_tile.dart @@ -58,25 +58,25 @@ class CommonListTile extends ListTile { ? Text("${model.categoryFatherName} ${DateFormat('yyyy-MM-dd').format(model.tradeTime)}") : Text(model.categoryFatherName), trailing: Text.rich( - style: const TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.normal), + style: TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.normal), TextSpan( children: displayUser ? [ AmountTextSpan.sameHeight( model.amount, - textStyle: const TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.w500), + textStyle: TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.w500), incomeExpense: model.incomeExpense, displayModel: IncomeExpenseDisplayModel.symbols, ), TextSpan( text: "\n${model.userName}", - style: const TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.normal), + style: TextStyle(fontSize: ConstantFontSize.body, fontWeight: FontWeight.normal), ) ] : [ AmountTextSpan.sameHeight( model.amount, - textStyle: const TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.w500), + textStyle: TextStyle(fontSize: ConstantFontSize.headline, fontWeight: FontWeight.w500), incomeExpense: model.incomeExpense, displayModel: displayModel, ) @@ -193,7 +193,7 @@ class _UserName extends StatelessWidget { mainAxisSize: MainAxisSize.min, children: [ Text(text), - const Padding(padding: EdgeInsets.only(left: Constant.margin / 2), child: CommonLabel(text: "我")) + Padding(padding: EdgeInsets.only(left: Constant.margin / 2), child: CommonLabel(text: "我")) ], ); } diff --git a/lib/widget/common/common_shimmer.dart b/lib/widget/common/common_shimmer.dart index 69402fa6..9a9c91ed 100644 --- a/lib/widget/common/common_shimmer.dart +++ b/lib/widget/common/common_shimmer.dart @@ -1,88 +1,13 @@ part of 'common.dart'; -Widget buildShimmer() { - return SingleChildScrollView( - padding: const EdgeInsets.all(16.0), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Shimmer.fromColors( - baseColor: Colors.grey.shade200, // 修改颜色为浅灰色 - highlightColor: Colors.grey.shade100, - - child: Container( - width: 250.0, // 调整宽度 - height: 20.0, - color: Colors.white, - ), - ), - const SizedBox(height: 16.0), - Shimmer.fromColors( - baseColor: Colors.grey.shade200, // 修改颜色为浅灰色 - highlightColor: Colors.grey.shade100, - child: Container( - width: 350.0, // 调整宽度 - height: 16.0, - color: Colors.white, - ), - ), - const SizedBox(height: 8.0), // 添加更多占位元素 - Shimmer.fromColors( - baseColor: Colors.grey.shade200, // 修改颜色为浅灰色 - highlightColor: Colors.grey.shade100, - child: Container( - width: 200.0, - height: 12.0, - color: Colors.white, - ), - ), - ], - ), - ); -} - -Widget buildShimmerList() { - return ListView.builder( - padding: const EdgeInsets.all(16.0), - itemCount: 10, // 重复渲染10次,可以根据需要调整 - itemBuilder: (context, index) { - return Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Shimmer.fromColors( - baseColor: Colors.grey.shade300, - highlightColor: Colors.grey.shade100, - child: Container( - width: 200.0, - height: 20.0, - color: Colors.white, - ), - ), - const SizedBox(height: 16.0), - Shimmer.fromColors( - baseColor: Colors.grey.shade300, - highlightColor: Colors.grey.shade100, - child: Container( - width: 300.0, - height: 16.0, - color: Colors.white, - ), - ), - const SizedBox(height: 32.0), // 调整需要的间距 - ], - ); - }, - ); -} - class ShimmerList extends StatelessWidget { const ShimmerList({super.key}); @override Widget build(BuildContext context) { return ListView.builder( - padding: const EdgeInsets.all(16.0), - itemCount: 10, // 重复渲染10次,可以根据需要调整 + padding: EdgeInsets.all(Constant.padding), + itemCount: 10, itemBuilder: (context, index) { return Column( crossAxisAlignment: CrossAxisAlignment.start, @@ -91,22 +16,22 @@ class ShimmerList extends StatelessWidget { baseColor: Colors.grey.shade300, highlightColor: Colors.grey.shade100, child: Container( - width: 200.0, - height: 20.0, + width: 200.0.w, + height: 20.0.sp, color: Colors.white, ), ), - const SizedBox(height: 16.0), + SizedBox(height: Constant.padding), Shimmer.fromColors( baseColor: Colors.grey.shade300, highlightColor: Colors.grey.shade100, child: Container( - width: 300.0, - height: 16.0, + width: 300.0.w, + height: 16.0.sp, color: Colors.white, ), ), - const SizedBox(height: 32.0), // 调整需要的间距 + SizedBox(height: Constant.padding * 2), ], ); }, diff --git a/lib/widget/common/common_toast.dart b/lib/widget/common/common_toast.dart index 22cc8a98..6040f03a 100644 --- a/lib/widget/common/common_toast.dart +++ b/lib/widget/common/common_toast.dart @@ -4,11 +4,19 @@ class CommonToast { const CommonToast(); static tipToast(String msg) { Fluttertoast.showToast( - msg: msg, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 5, fontSize: 16.0); + msg: msg, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 5, + fontSize: ConstantFontSize.bodyLarge); } static errorToast(String msg) { Fluttertoast.showToast( - msg: msg, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 5, fontSize: 16.0); + msg: msg, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 5, + fontSize: ConstantFontSize.bodyLarge); } } diff --git a/lib/widget/common/page/common_page.dart b/lib/widget/common/page/common_page.dart index e5b1c77d..0e13310d 100644 --- a/lib/widget/common/page/common_page.dart +++ b/lib/widget/common/page/common_page.dart @@ -136,14 +136,14 @@ class _CommonPageListState extends State> with SingleTicker } Widget _buildNoData() { - return const SliverToBoxAdapter( - child: SizedBox(height: 64, child: Center(child: NoData.commonWidget)), + return SliverToBoxAdapter( + child: SizedBox(height: 64.sp, child: Center(child: NoData.commonWidget)), ); } Widget _buildLoading() { return SliverToBoxAdapter( - child: RefreshAnimation(key: _refreshAnimationKey, height: 78), + child: RefreshAnimation(key: _refreshAnimationKey, height: 78.sp), ); } } diff --git a/lib/widget/common/page/enter.dart b/lib/widget/common/page/enter.dart index 33e727cb..5cc38d1a 100644 --- a/lib/widget/common/page/enter.dart +++ b/lib/widget/common/page/enter.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; part 'common_page.dart'; part 'controller.dart'; diff --git a/lib/widget/common/page/refresh_animation.dart b/lib/widget/common/page/refresh_animation.dart index 5f3e5b15..9ad05ca8 100644 --- a/lib/widget/common/page/refresh_animation.dart +++ b/lib/widget/common/page/refresh_animation.dart @@ -25,11 +25,11 @@ class _RefreshAnimationState extends State with SingleTickerPr ); curvedAnimation = CurvedAnimation(parent: _controller, curve: Curves.easeInOut); _heightAnimation = Tween( - begin: widget.height, + begin: widget.height.sp, end: 0, ).animate(curvedAnimation); _positionAnimation = Tween( - begin: (widget.height - 36) / 2, + begin: (widget.height.sp - 36) / 2, end: 0, ).animate(curvedAnimation); @@ -131,9 +131,7 @@ class _TestRefreshAnimationState extends State { RefreshAnimation( key: refreshAnimation, ), - const SizedBox( - height: 100, - ), + SizedBox(height: 100.sp), TextButton( onPressed: () { setState(() { diff --git a/lib/widget/date/enter.dart b/lib/widget/date/enter.dart index 5bd54a7e..6ac360e5 100644 --- a/lib/widget/date/enter.dart +++ b/lib/widget/date/enter.dart @@ -2,6 +2,7 @@ import 'dart:async'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/util/enter.dart'; diff --git a/lib/widget/date/month_or_date_range_picker.dart b/lib/widget/date/month_or_date_range_picker.dart index bc02f5a3..f94a4052 100644 --- a/lib/widget/date/month_or_date_range_picker.dart +++ b/lib/widget/date/month_or_date_range_picker.dart @@ -78,7 +78,7 @@ class _MonthOrDateRangePickerState extends State with Si switch (widget.mode) { case Mode.month: child = _buildMonthPicker(); - title = const Padding( + title = Padding( padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), child: Text( '月份选择', @@ -92,7 +92,7 @@ class _MonthOrDateRangePickerState extends State with Si break; case Mode.dateRange: child = _buildDateRangePicker(); - title = const Padding( + title = Padding( padding: EdgeInsets.fromLTRB(Constant.padding, Constant.padding, Constant.padding, 0), child: Text( '日期选择', @@ -117,7 +117,7 @@ class _MonthOrDateRangePickerState extends State with Si children: [ title, Container( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: child, ) ], @@ -132,7 +132,7 @@ class _MonthOrDateRangePickerState extends State with Si crossAxisAlignment: CrossAxisAlignment.start, children: [ SizedBox( - height: 300, + height: 300.sp, child: CupertinoDatePicker( mode: CupertinoDatePickerMode.monthYear, initialDateTime: selectedMonth, @@ -157,17 +157,17 @@ class _MonthOrDateRangePickerState extends State with Si crossAxisAlignment: CrossAxisAlignment.start, children: [ Padding( - padding: const EdgeInsets.only(top: Constant.margin), + padding: EdgeInsets.only(top: Constant.margin), child: _buildButtonGroup(), ), - const SizedBox(height: 20), + SizedBox(height: 20), // 时间输入框 Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.center, children: [ Expanded(flex: 5, child: _buildInputButton(isStartInputButton: true)), - const Expanded( + Expanded( child: Padding(padding: EdgeInsets.all(Constant.margin), child: Divider(color: Colors.black87)), ), Expanded(flex: 5, child: _buildInputButton(isStartInputButton: false)), @@ -175,7 +175,7 @@ class _MonthOrDateRangePickerState extends State with Si ), // 日期滚轮 SizedBox( - height: 300, + height: 300.sp, child: CupertinoDatePicker( key: selectedStartInputButton ? startDatePickerKey : endDatePickerKey, mode: CupertinoDatePickerMode.date, @@ -275,9 +275,9 @@ class _MonthOrDateRangePickerState extends State with Si onSubmit(); }, child: Container( - height: 28, - margin: const EdgeInsets.all(Constant.margin / 2), - padding: const EdgeInsets.symmetric(horizontal: Constant.margin), + height: 28.sp, + margin: EdgeInsets.all(Constant.margin / 2), + padding: EdgeInsets.symmetric(horizontal: Constant.margin), decoration: BoxDecoration( border: Border.all( color: isSelected ? ConstantColor.primaryColor : Colors.grey, @@ -305,7 +305,7 @@ class _MonthOrDateRangePickerState extends State with Si selectedStartInputButton = isStartInputButton; }), child: Container( - padding: const EdgeInsets.symmetric(vertical: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.padding), decoration: BoxDecoration( border: Border( bottom: BorderSide( @@ -318,7 +318,7 @@ class _MonthOrDateRangePickerState extends State with Si child: Text( isStartInputButton ? DateFormat('yyyy-MM-dd').format(startDate) : DateFormat('yyyy-MM-dd').format(endDate), style: TextStyle( - fontSize: 18, + fontSize: ConstantFontSize.largeHeadline, color: selectedStartInputButton == isStartInputButton ? ConstantColor.primaryColor : Colors.black, ), ), @@ -331,7 +331,7 @@ class _MonthOrDateRangePickerState extends State with Si Widget _buildSumbitButton() { return SizedBox( width: double.infinity, - child: ElevatedButton(onPressed: onSubmit, child: const Text('确定')), + child: ElevatedButton(onPressed: onSubmit, child: Text('确定')), ); } diff --git a/lib/widget/form/form.dart b/lib/widget/form/form.dart index dac86af8..0c7b332f 100644 --- a/lib/widget/form/form.dart +++ b/lib/widget/form/form.dart @@ -13,13 +13,11 @@ Widget saveButton(BuildContext context, Function(BuildContext context) submitFor return ElevatedButton( onPressed: () => submitForm(context), style: ElevatedButton.styleFrom( - padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 32.0), + padding: EdgeInsets.symmetric(vertical: Constant.padding, horizontal: Constant.padding * 2), ), child: const Text( '保 存', - style: TextStyle( - fontSize: 18.0, - ), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline), ), ); } diff --git a/lib/widget/form/form_button.dart b/lib/widget/form/form_button.dart index 877ad056..3f26b040 100644 --- a/lib/widget/form/form_button.dart +++ b/lib/widget/form/form_button.dart @@ -9,9 +9,7 @@ class FormButton { ), child: const Text( '保 存', - style: TextStyle( - fontSize: 18.0, - ), + style: TextStyle(fontSize: ConstantFontSize.largeHeadline), ), ); } @@ -27,7 +25,7 @@ class FormButton { borderRadius: BorderRadius.circular(10.0), ), ), - child: const Text( + child: Text( '保存', style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.w500, letterSpacing: Constant.margin / 2), ), diff --git a/lib/widget/form/form_input_field.dart b/lib/widget/form/form_input_field.dart index f325e4f2..3c447e4e 100644 --- a/lib/widget/form/form_input_field.dart +++ b/lib/widget/form/form_input_field.dart @@ -3,7 +3,7 @@ part of 'form.dart'; class FormInputField { static Widget string(String fieldName, String initialValue, void Function(String)? onChanged) { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -102,12 +102,11 @@ class FormInputField { void Function(String?)? onSave, }) { return Container( - padding: const EdgeInsets.symmetric(horizontal: Constant.margin), - margin: const EdgeInsets.only(right: Constant.margin), - decoration: - const BoxDecoration(color: ConstantColor.greyBackground, borderRadius: ConstantDecoration.borderRadius), + padding: EdgeInsets.symmetric(horizontal: Constant.margin), + margin: EdgeInsets.only(right: Constant.margin), + decoration: BoxDecoration(color: ConstantColor.greyBackground, borderRadius: ConstantDecoration.borderRadius), child: TextFormField( - decoration: const InputDecoration( + decoration: InputDecoration( icon: Icon(Icons.search_rounded), border: InputBorder.none, ), diff --git a/lib/widget/form/form_select_field.dart b/lib/widget/form/form_select_field.dart index 1931f92d..4786f896 100644 --- a/lib/widget/form/form_select_field.dart +++ b/lib/widget/form/form_select_field.dart @@ -9,14 +9,14 @@ class BaseFormSelectField extends StatelessWidget { @override Widget build(BuildContext context) { return Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), + padding: EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.padding), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Text(label, style: TextStyle(letterSpacing: Constant.margin / 2)), ), Expanded( diff --git a/lib/widget/form/form_selecter.dart b/lib/widget/form/form_selecter.dart index c66222d0..619fc577 100644 --- a/lib/widget/form/form_selecter.dart +++ b/lib/widget/form/form_selecter.dart @@ -191,7 +191,7 @@ class _BottomSelecterState extends State ); } child = Padding( - padding: const EdgeInsets.only(top: Constant.buttomSheetRadius, bottom: Constant.margin), + padding: EdgeInsets.only(top: Constant.buttomSheetRadius, bottom: Constant.margin), child: DecoratedBox( decoration: BoxDecoration( color: widget.backgroundColor, @@ -231,7 +231,7 @@ class BottomCupertinoSelecter extends bottomSelecter { required super.onTap, super.selected, super.backgroundColor, - double? height = Constant.buttomHight, + double? height, }) : super(height: height ?? Constant.buttomHight); @override @@ -268,7 +268,7 @@ class _BottomCupertinoSelecterState extends State { mainAxisSize: MainAxisSize.min, children: [ Padding( - padding: const EdgeInsets.symmetric(horizontal: Constant.padding), + padding: EdgeInsets.symmetric(horizontal: Constant.padding), child: FormInputField.general( onChanged: (String? input) { this.input = input ?? ""; diff --git a/lib/widget/icon/circular_icon.dart b/lib/widget/icon/circular_icon.dart index 2ef8b72f..c26b7076 100644 --- a/lib/widget/icon/circular_icon.dart +++ b/lib/widget/icon/circular_icon.dart @@ -15,13 +15,9 @@ class CircularIcon extends StatelessWidget { color: backgroundColor, borderRadius: BorderRadius.circular(90), ), - width: 64, - height: 64, - child: Icon( - icon, - size: 32, - color: Colors.black87, - ), + width: 64.sp, + height: 64.sp, + child: Icon(icon, size: Constant.iconlargeSize, color: Colors.black87), ); } } diff --git a/lib/widget/icon/enter.dart b/lib/widget/icon/enter.dart index 75b05e95..777d8378 100644 --- a/lib/widget/icon/enter.dart +++ b/lib/widget/icon/enter.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:leap_ledger_app/common/global.dart'; part 'circular_icon.dart'; diff --git a/lib/widget/toast.dart b/lib/widget/toast.dart index 9dbf633e..a66220d3 100644 --- a/lib/widget/toast.dart +++ b/lib/widget/toast.dart @@ -1,6 +1,11 @@ import 'package:fluttertoast/fluttertoast.dart'; +import 'package:leap_ledger_app/common/global.dart'; tipToast(String msg) { Fluttertoast.showToast( - msg: msg, toastLength: Toast.LENGTH_SHORT, gravity: ToastGravity.BOTTOM, timeInSecForIosWeb: 5, fontSize: 16.0); + msg: msg, + toastLength: Toast.LENGTH_SHORT, + gravity: ToastGravity.BOTTOM, + timeInSecForIosWeb: 5, + fontSize: ConstantFontSize.bodyLarge); } diff --git a/lib/widget/transaction/enter.dart b/lib/widget/transaction/enter.dart index 125a4a3a..964122e6 100644 --- a/lib/widget/transaction/enter.dart +++ b/lib/widget/transaction/enter.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:intl/intl.dart'; import 'package:leap_ledger_app/common/global.dart'; import 'package:leap_ledger_app/model/transaction/model.dart'; diff --git a/lib/widget/transaction/transaction_container.dart b/lib/widget/transaction/transaction_container.dart index 7abd5ea4..1f8c8329 100644 --- a/lib/widget/transaction/transaction_container.dart +++ b/lib/widget/transaction/transaction_container.dart @@ -8,13 +8,13 @@ class TransactionContainer extends StatelessWidget { return DecoratedBox( decoration: ConstantDecoration.cardDecoration, child: Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Row( mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Icon( trans.categoryIcon, color: ConstantColor.primaryColor, @@ -27,7 +27,7 @@ class TransactionContainer extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DefaultTextStyle.merge( - style: TextStyle(fontSize: ConstantFontSize.body, height: 1.5), + style: TextStyle(fontSize: ConstantFontSize.body, height: 1.5.sp), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, @@ -39,7 +39,7 @@ class TransactionContainer extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Text.rich( AmountTextSpan.sameHeight( trans.amount, @@ -78,7 +78,7 @@ class TransactionTimingContainer extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Padding( - padding: const EdgeInsets.all(Constant.padding), + padding: EdgeInsets.all(Constant.padding), child: Icon( trans.categoryIcon, color: ConstantColor.primaryColor, @@ -91,7 +91,7 @@ class TransactionTimingContainer extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ DefaultTextStyle.merge( - style: TextStyle(fontSize: ConstantFontSize.body, height: 1.5), + style: TextStyle(fontSize: ConstantFontSize.body, height: 1.5.sp), child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.start, @@ -103,13 +103,11 @@ class TransactionTimingContainer extends StatelessWidget { ), ), Padding( - padding: const EdgeInsets.all(Constant.margin), + padding: EdgeInsets.all(Constant.margin), child: Text.rich( AmountTextSpan.sameHeight( trans.amount, - textStyle: TextStyle( - fontSize: ConstantFontSize.largeHeadline, - ), + textStyle: TextStyle(fontSize: ConstantFontSize.largeHeadline), incomeExpense: trans.incomeExpense, displayModel: IncomeExpenseDisplayModel.symbols, ), @@ -129,7 +127,7 @@ class TransactionTimingContainer extends StatelessWidget { child: DecoratedBox( decoration: BoxDecoration(color: Colors.white), child: Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.margin), + padding: EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.margin), child: child, ), ), @@ -139,7 +137,7 @@ class TransactionTimingContainer extends StatelessWidget { return DecoratedBox( decoration: ConstantDecoration.cardDecoration, child: Padding( - padding: const EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.margin), + padding: EdgeInsets.symmetric(vertical: Constant.margin, horizontal: Constant.margin), child: child, ), ); @@ -149,9 +147,9 @@ class TransactionTimingContainer extends StatelessWidget { return Row( mainAxisSize: MainAxisSize.min, children: [ - const VerticalDivider(color: ConstantColor.greyText, width: Constant.margin, thickness: 1), + VerticalDivider(color: ConstantColor.greyText, width: Constant.margin, thickness: 1), Center( - child: SizedBox(width: 64, child: Text(config.toDisplay(), textAlign: TextAlign.center)), + child: SizedBox(width: 64.sp, child: Text(config.toDisplay(), textAlign: TextAlign.center)), ) ], ); diff --git a/pubspec.yaml b/pubspec.yaml index 9750efaf..8feeb4dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -43,7 +43,8 @@ dependencies: device_info_plus: ^10.1.2 web_socket_channel: ^3.0.1 flutter_slidable: ^3.1.1 - + flutter_screenutil: ^5.9.3 + dev_dependencies: flutter_test: sdk: flutter