添加 国际化

添加app风格
master
张萌 2 years ago
parent 54fdafd329
commit 5279ced9c2

@ -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: <ThemeExtension<dynamic>>[
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<Color?>((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<MyAppStyle> {
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<MyAppStyle> lerp(ThemeExtension<MyAppStyle>? 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,
});
}

@ -0,0 +1,6 @@
{
"appName":"云云问车",
"@appName":{
"description":"应用名称"
}
}

@ -3,7 +3,7 @@ import 'package:json_annotation/json_annotation.dart';
part 'base_list_model.g.dart';
@JsonSerializable()
class BaseListModel<T> {
class BaseListModel {
final int code;
final String msg;
final ListInnerModel? data;

@ -0,0 +1,35 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'base_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BaseListModel _$BaseListModelFromJson(Map<String, dynamic> json) =>
BaseListModel(
code: json['code'] as int,
msg: json['msg'] as String,
data: json['data'] == null
? null
: ListInnerModel.fromJson(json['data'] as Map<String, dynamic>),
);
Map<String, dynamic> _$BaseListModelToJson(BaseListModel instance) =>
<String, dynamic>{
'code': instance.code,
'msg': instance.msg,
'data': instance.data,
};
ListInnerModel _$ListInnerModelFromJson(Map<String, dynamic> json) =>
ListInnerModel(
list: json['list'] as List<dynamic>?,
total: json['total'] as int,
);
Map<String, dynamic> _$ListInnerModelToJson(ListInnerModel instance) =>
<String, dynamic>{
'list': instance.list,
'total': instance.total,
};

@ -0,0 +1,20 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'base_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
BaseModel<T> _$BaseModelFromJson<T>(Map<String, dynamic> json) => BaseModel<T>(
code: json['code'] as int,
msg: json['msg'] as String,
data: json['data'],
);
Map<String, dynamic> _$BaseModelToJson<T>(BaseModel<T> instance) =>
<String, dynamic>{
'code': instance.code,
'msg': instance.msg,
'data': instance.data,
};

@ -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';

@ -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<UserProvider>(Get.context!, listen: false);
static MyAppStyle get myAppStyle =>
Theme.of(Get.context!).extension<MyAppStyle>()!;
}
Loading…
Cancel
Save