You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

216 lines
6.6 KiB

4 years ago
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
3 years ago
4 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
class AppTheme {
static ThemeData get theme {
return ThemeData(primarySwatch: Colors.blue).copyWith(
extensions: <ThemeExtension<dynamic>>[
MyAppStyle(
mainColor: Colors.blue,
bodyText3: TextStyle(
fontSize: 30.sp,
color: const Color(0xFF333333),
),
)
],
progressIndicatorTheme:
ProgressIndicatorThemeData(color: Color(0xFFFFD000)),
4 years ago
primaryColor: Color(0xFFFFD000),
textTheme: ThemeData.light().textTheme.copyWith(
3 years ago
caption: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333),
),
overline: TextStyle(
fontSize: 32.sp,
color: Color(0xFF333333),
),
headline1: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
headline2: TextStyle(
fontSize: 30.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
headline3: TextStyle(
fontSize: 32.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
headline4: TextStyle(
fontSize: 36.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
3 years ago
headline5: TextStyle(
fontSize: 40.sp,
color: Color(0xFF333333),
fontWeight: FontWeight.bold,
),
subtitle1: TextStyle(
fontSize: 32.sp,
color: Color(0xFF333333),
),
subtitle2: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333),
),
bodyText1: TextStyle(
fontSize: 24.sp,
color: Color(0xFF333333),
),
bodyText2: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333),
),
button: TextStyle(
fontSize: 28.sp,
color: Color(0xFF333333),
)),
4 years ago
floatingActionButtonTheme: FloatingActionButtonThemeData().copyWith(
backgroundColor: Color(0xFFFFD000),
),
3 years ago
appBarTheme: AppBarTheme().copyWith(
4 years ago
elevation: 0,
centerTitle: true,
iconTheme: IconThemeData(
color: Color(0xFF333333),
),
systemOverlayStyle: SystemUiOverlayStyle.dark,
toolbarTextStyle: TextTheme(
4 years ago
headline6: TextStyle(
color: Color(0xFF333333),
fontSize: 36.sp,
fontWeight: FontWeight.bold,
4 years ago
),
).bodyText2,
titleTextStyle: TextTheme(
3 years ago
headline3: TextStyle(
color: Color(0xFF333333),
3 years ago
fontSize: 32.sp,
fontWeight: FontWeight.bold,
),
3 years ago
).headline3,
4 years ago
),
3 years ago
tabBarTheme: TabBarTheme().copyWith(
4 years ago
labelColor: Color(0xFF333333),
labelStyle: TextStyle(
3 years ago
fontSize: 30.sp,
fontWeight: FontWeight.bold,
4 years ago
),
3 years ago
unselectedLabelStyle:
TextStyle(fontSize: 28.sp, fontWeight: FontWeight.normal),
4 years ago
indicatorSize: TabBarIndicatorSize.label,
),
3 years ago
bottomNavigationBarTheme: BottomNavigationBarThemeData().copyWith(
selectedItemColor: Color(0xFF333333),
selectedLabelStyle: TextStyle(
fontWeight: FontWeight.bold,
),
type: BottomNavigationBarType.fixed,
unselectedLabelStyle: TextStyle(),
),
3 years ago
radioTheme: RadioThemeData().copyWith(
4 years ago
fillColor: MaterialStateProperty.resolveWith<Color?>((states) {
if (states.contains(MaterialState.selected)) return Color(0xFFFFD000);
return null;
}),
),
elevatedButtonTheme: ElevatedButtonThemeData(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled))
return Color(0xFFFFF4D7);
return Color(0xFFFFD000);
}),
elevation: MaterialStateProperty.all(0),
foregroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled))
return Color(0xFF666666);
return 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 Color(0xFFFFF4D7);
return Color(0xFFFFD000).withOpacity(0.2);
}),
foregroundColor: MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled))
return Color(0xFF666666);
return Color(0xFF333333);
}),
),
),
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
dividerColor: Color(0xFFE8E8E8),
colorScheme:
ColorScheme.fromSwatch().copyWith(secondary: Color(0xFFFFD000)),
4 years ago
);
}
}
class SystemStyle {
static const initial = SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
systemNavigationBarColor: Colors.white,
);
static const yellowBottomBar = SystemUiOverlayStyle(
statusBarIconBrightness: Brightness.light,
systemNavigationBarColor: Color(0xFFFFD000),
);
4 years ago
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,
});
}