From 5279ced9c2f0208d70811cd4c0304617b16352de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E8=90=8C?= <494089941@qq.com> Date: Thu, 9 Jun 2022 10:41:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E5=8C=96=20=E6=B7=BB=E5=8A=A0app=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/constants/app_ theme.dart | 193 ++++++++++++++++++ lib/l10n/app_zh.arb | 6 + ..._llist_model.dart => base_list_model.dart} | 2 +- .../inner_models/base_list_model.g.dart | 35 ++++ .../{base_modell.dart => base_model.dart} | 0 lib/models/inner_models/base_model.g.dart | 20 ++ lib/utils/api_client.dart | 4 +- lib/utils/user_tool.dart | 13 ++ 8 files changed, 270 insertions(+), 3 deletions(-) create mode 100644 lib/constants/app_ theme.dart create mode 100644 lib/l10n/app_zh.arb rename lib/models/inner_models/{base_llist_model.dart => base_list_model.dart} (97%) create mode 100644 lib/models/inner_models/base_list_model.g.dart rename lib/models/inner_models/{base_modell.dart => base_model.dart} (100%) create mode 100644 lib/models/inner_models/base_model.g.dart create mode 100644 lib/utils/user_tool.dart diff --git a/lib/constants/app_ theme.dart b/lib/constants/app_ theme.dart new file mode 100644 index 0000000..1245f52 --- /dev/null +++ b/lib/constants/app_ theme.dart @@ -0,0 +1,193 @@ +import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class AppTheme { + static ThemeData get theme { + return ThemeData(primarySwatch: Colors.blue).copyWith( + primaryColor: const Color(0xFF027AFF), + extensions: >[ + MyAppStyle( + mainColor: Colors.blue, + bodyText3: TextStyle( + fontSize: 30.sp, + color: const Color(0xFF333333), + ), + ) + ], + textTheme: ThemeData.light().textTheme.copyWith( + headline3: TextStyle( + fontSize: 40.sp, + color: const Color(0xFF333333), + fontWeight: FontWeight.bold, + ), + headline4: TextStyle( + fontSize: 36.sp, + color: const Color(0xFF111111), + fontWeight: FontWeight.bold, + ), + subtitle1: TextStyle( + fontSize: 32.sp, + color: const Color(0xFF333333), + ), + subtitle2: TextStyle( + fontSize: 28.sp, + color: const Color(0xFF333333), + ), + bodyText1: TextStyle( + fontSize: 24.sp, + color: const Color(0xFF333333), + ), + bodyText2: TextStyle( + fontSize: 28.sp, + color: const Color(0xFF333333), + ), + ), + floatingActionButtonTheme: const FloatingActionButtonThemeData().copyWith( + backgroundColor: Colors.blue, + ), + appBarTheme: AppBarTheme( + elevation: 0, + centerTitle: true, + iconTheme: const IconThemeData( + color: Color(0xFF333333), + ), + systemOverlayStyle: SystemUiOverlayStyle.dark, + toolbarTextStyle: TextTheme( + headline6: TextStyle( + color: const Color(0xFF333333), + fontSize: 36.sp, + fontWeight: FontWeight.bold, + ), + ).bodyText2, + titleTextStyle: TextTheme( + headline6: TextStyle( + color: const Color(0xFF333333), + fontSize: 36.sp, + fontWeight: FontWeight.bold, + ), + ).headline6, + ), + tabBarTheme: TabBarTheme( + labelColor: const Color(0xFF333333), + labelStyle: TextStyle( + fontSize: 28.sp, + fontWeight: FontWeight.w600, + ), + unselectedLabelStyle: TextStyle( + fontSize: 28.sp, + ), + indicatorSize: TabBarIndicatorSize.label, + ), + bottomNavigationBarTheme: const BottomNavigationBarThemeData( + selectedItemColor: Color(0xFF333333), + selectedLabelStyle: TextStyle( + fontWeight: FontWeight.bold, + ), + type: BottomNavigationBarType.fixed, + unselectedLabelStyle: TextStyle(), + ), + radioTheme: RadioThemeData( + fillColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.selected)) { + return const Color(0xFFFFD000); + } + return null; + }), + ), + elevatedButtonTheme: ElevatedButtonThemeData( + style: ButtonStyle( + backgroundColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) { + return const Color(0xFFFFF4D7); + } + return const Color(0xFFFFD000); + }), + elevation: MaterialStateProperty.all(0), + foregroundColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) { + return const Color(0xFF666666); + } + return const Color(0xFF333333); + }), + textStyle: MaterialStateProperty.all(TextStyle( + fontSize: 32.sp, + fontWeight: FontWeight.bold, + )), + padding: MaterialStateProperty.all( + EdgeInsets.symmetric(horizontal: 76.w, vertical: 22.w), + ), + enableFeedback: true, + ), + ), + textButtonTheme: TextButtonThemeData( + style: ButtonStyle( + overlayColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) { + return const Color(0xFFFFF4D7); + } + return const Color(0xFFFFD000).withOpacity(0.2); + }), + foregroundColor: MaterialStateProperty.resolveWith((states) { + if (states.contains(MaterialState.disabled)) { + return const Color(0xFF666666); + } + return const Color(0xFF333333); + }), + ), + ), + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + dividerColor: const Color(0xFFE8E8E8), + colorScheme: ColorScheme.fromSwatch() + .copyWith(secondary: const Color(0xFF027AFF)) + .copyWith(secondary: const Color(0xFF027AFF)), + ); + } +} + +class SystemStyle { + static const initial = SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.light, + systemNavigationBarColor: Colors.white, + ); + + static const yellowBottomBar = SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.light, + systemNavigationBarColor: Color(0xFFFFD000), + ); + + static genStyle({required Color bottom}) { + return SystemUiOverlayStyle( + statusBarIconBrightness: Brightness.light, + systemNavigationBarColor: bottom, + ); + } +} + +@immutable +class MyAppStyle extends ThemeExtension { + final TextStyle? bodyText3; + final Color? mainColor; + @override + MyAppStyle copyWith({Color? mainColor, TextStyle? bodyText3}) { + return MyAppStyle( + mainColor: mainColor ?? this.mainColor, + bodyText3: bodyText3 ?? this.bodyText3); + } + + @override + ThemeExtension lerp(ThemeExtension? other, double t) { + if (other is! MyAppStyle) { + return this; + } + return MyAppStyle( + mainColor: Color.lerp(mainColor, other.mainColor, t), + bodyText3: TextStyle.lerp(bodyText3, other.bodyText3, t), + ); + } + + const MyAppStyle({ + this.bodyText3, + this.mainColor, + }); +} diff --git a/lib/l10n/app_zh.arb b/lib/l10n/app_zh.arb new file mode 100644 index 0000000..9ecc394 --- /dev/null +++ b/lib/l10n/app_zh.arb @@ -0,0 +1,6 @@ +{ + "appName":"云云问车", + "@appName":{ + "description":"应用名称" + } +} \ No newline at end of file diff --git a/lib/models/inner_models/base_llist_model.dart b/lib/models/inner_models/base_list_model.dart similarity index 97% rename from lib/models/inner_models/base_llist_model.dart rename to lib/models/inner_models/base_list_model.dart index 3cd1d68..c620832 100644 --- a/lib/models/inner_models/base_llist_model.dart +++ b/lib/models/inner_models/base_list_model.dart @@ -3,7 +3,7 @@ import 'package:json_annotation/json_annotation.dart'; part 'base_list_model.g.dart'; @JsonSerializable() -class BaseListModel { +class BaseListModel { final int code; final String msg; final ListInnerModel? data; diff --git a/lib/models/inner_models/base_list_model.g.dart b/lib/models/inner_models/base_list_model.g.dart new file mode 100644 index 0000000..2ac593c --- /dev/null +++ b/lib/models/inner_models/base_list_model.g.dart @@ -0,0 +1,35 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'base_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BaseListModel _$BaseListModelFromJson(Map json) => + BaseListModel( + code: json['code'] as int, + msg: json['msg'] as String, + data: json['data'] == null + ? null + : ListInnerModel.fromJson(json['data'] as Map), + ); + +Map _$BaseListModelToJson(BaseListModel instance) => + { + 'code': instance.code, + 'msg': instance.msg, + 'data': instance.data, + }; + +ListInnerModel _$ListInnerModelFromJson(Map json) => + ListInnerModel( + list: json['list'] as List?, + total: json['total'] as int, + ); + +Map _$ListInnerModelToJson(ListInnerModel instance) => + { + 'list': instance.list, + 'total': instance.total, + }; diff --git a/lib/models/inner_models/base_modell.dart b/lib/models/inner_models/base_model.dart similarity index 100% rename from lib/models/inner_models/base_modell.dart rename to lib/models/inner_models/base_model.dart diff --git a/lib/models/inner_models/base_model.g.dart b/lib/models/inner_models/base_model.g.dart new file mode 100644 index 0000000..aa90837 --- /dev/null +++ b/lib/models/inner_models/base_model.g.dart @@ -0,0 +1,20 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'base_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +BaseModel _$BaseModelFromJson(Map json) => BaseModel( + code: json['code'] as int, + msg: json['msg'] as String, + data: json['data'], + ); + +Map _$BaseModelToJson(BaseModel instance) => + { + 'code': instance.code, + 'msg': instance.msg, + 'data': instance.data, + }; diff --git a/lib/utils/api_client.dart b/lib/utils/api_client.dart index 22e0262..292d542 100644 --- a/lib/utils/api_client.dart +++ b/lib/utils/api_client.dart @@ -1,8 +1,8 @@ import 'dart:io'; import 'package:cloud_car_internal/constants/api/api.dart'; -import 'package:cloud_car_internal/models/inner_models/base_llist_model.dart'; -import 'package:cloud_car_internal/models/inner_models/base_modell.dart'; +import 'package:cloud_car_internal/models/inner_models/base_list_model.dart'; +import 'package:cloud_car_internal/models/inner_models/base_model.dart'; import 'package:cloud_car_internal/utils/toast/cloud_toast.dart'; import 'package:dio/dio.dart'; import 'package:flutter/foundation.dart'; diff --git a/lib/utils/user_tool.dart b/lib/utils/user_tool.dart new file mode 100644 index 0000000..782d675 --- /dev/null +++ b/lib/utils/user_tool.dart @@ -0,0 +1,13 @@ + +import 'package:cloud_car_internal/constants/api/app_theme.dart'; +import 'package:flutter/material.dart'; +import 'package:get/get.dart'; +import 'package:provider/provider.dart'; +import '../providers/user_provider.dart'; + +class UserTool { + static UserProvider userProvider = + Provider.of(Get.context!, listen: false); + static MyAppStyle get myAppStyle => + Theme.of(Get.context!).extension()!; +}