v1.0.1
This commit is contained in:
167
lib/app/app_style.dart
Normal file
167
lib/app/app_style.dart
Normal file
@@ -0,0 +1,167 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_dmzj/app/app_color.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class AppStyle {
|
||||
static ThemeData lightTheme = getLightTheme();
|
||||
static ThemeData getLightTheme({ColorScheme? colorScheme}) {
|
||||
final scheme = colorScheme ?? AppColor.colorSchemeLight;
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: scheme,
|
||||
brightness: Brightness.light,
|
||||
).copyWith(
|
||||
scaffoldBackgroundColor: colorScheme != null ? null : Colors.white,
|
||||
cardColor: colorScheme != null ? null : Colors.white,
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: scheme.onSurface,
|
||||
centerTitle: false,
|
||||
shape: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
iconTheme: IconThemeData(
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
titleTextStyle: TextStyle(
|
||||
fontSize: 16,
|
||||
color: scheme.onSurface,
|
||||
),
|
||||
systemOverlayStyle: SystemUiOverlayStyle.dark.copyWith(
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
static ThemeData darkTheme = getDarkTheme();
|
||||
static ThemeData getDarkTheme({ColorScheme? colorScheme}) {
|
||||
final scheme = colorScheme ?? AppColor.colorSchemeDark;
|
||||
return ThemeData(
|
||||
useMaterial3: true,
|
||||
colorScheme: scheme,
|
||||
brightness: Brightness.dark,
|
||||
).copyWith(
|
||||
primaryColor: scheme.primary,
|
||||
cardColor: const Color(0xff424242),
|
||||
scaffoldBackgroundColor: Colors.black,
|
||||
tabBarTheme: TabBarThemeData(
|
||||
indicatorColor: scheme.primary,
|
||||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
backgroundColor: Colors.transparent,
|
||||
foregroundColor: Colors.white,
|
||||
centerTitle: false,
|
||||
shape: Border(
|
||||
bottom: BorderSide(
|
||||
color: Colors.grey.withOpacity(.2),
|
||||
width: 1,
|
||||
),
|
||||
),
|
||||
titleTextStyle: const TextStyle(
|
||||
fontSize: 16,
|
||||
color: Colors.white,
|
||||
),
|
||||
iconTheme: const IconThemeData(
|
||||
color: Colors.white,
|
||||
),
|
||||
systemOverlayStyle: SystemUiOverlayStyle.light.copyWith(
|
||||
systemNavigationBarColor: Colors.transparent,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
static const vGap4 = SizedBox(
|
||||
height: 4,
|
||||
);
|
||||
static const vGap8 = SizedBox(
|
||||
height: 8,
|
||||
);
|
||||
static const vGap12 = SizedBox(
|
||||
height: 12,
|
||||
);
|
||||
static const vGap24 = SizedBox(
|
||||
height: 24,
|
||||
);
|
||||
static const vGap32 = SizedBox(
|
||||
height: 32,
|
||||
);
|
||||
|
||||
static const hGap4 = SizedBox(
|
||||
width: 4,
|
||||
);
|
||||
static const hGap8 = SizedBox(
|
||||
width: 8,
|
||||
);
|
||||
static const hGap12 = SizedBox(
|
||||
width: 12,
|
||||
);
|
||||
static const hGap16 = SizedBox(
|
||||
width: 16,
|
||||
);
|
||||
|
||||
static const hGap24 = SizedBox(
|
||||
width: 24,
|
||||
);
|
||||
static const hGap32 = SizedBox(
|
||||
width: 32,
|
||||
);
|
||||
|
||||
static const edgeInsetsH4 = EdgeInsets.symmetric(horizontal: 4);
|
||||
static const edgeInsetsH8 = EdgeInsets.symmetric(horizontal: 8);
|
||||
static const edgeInsetsH12 = EdgeInsets.symmetric(horizontal: 12);
|
||||
static const edgeInsetsH16 = EdgeInsets.symmetric(horizontal: 16);
|
||||
static const edgeInsetsH20 = EdgeInsets.symmetric(horizontal: 20);
|
||||
static const edgeInsetsH24 = EdgeInsets.symmetric(horizontal: 24);
|
||||
|
||||
static const edgeInsetsV4 = EdgeInsets.symmetric(vertical: 4);
|
||||
static const edgeInsetsV8 = EdgeInsets.symmetric(vertical: 8);
|
||||
static const edgeInsetsV12 = EdgeInsets.symmetric(vertical: 12);
|
||||
static const edgeInsetsV24 = EdgeInsets.symmetric(vertical: 24);
|
||||
|
||||
static const edgeInsetsA4 = EdgeInsets.all(4);
|
||||
static const edgeInsetsA8 = EdgeInsets.all(8);
|
||||
static const edgeInsetsA12 = EdgeInsets.all(12);
|
||||
static const edgeInsetsA24 = EdgeInsets.all(24);
|
||||
|
||||
static const edgeInsetsR4 = EdgeInsets.only(right: 4);
|
||||
static const edgeInsetsR8 = EdgeInsets.only(right: 8);
|
||||
static const edgeInsetsR12 = EdgeInsets.only(right: 12);
|
||||
static const edgeInsetsR20 = EdgeInsets.only(right: 20);
|
||||
static const edgeInsetsR24 = EdgeInsets.only(right: 24);
|
||||
|
||||
static const edgeInsetsL4 = EdgeInsets.only(left: 4);
|
||||
static const edgeInsetsL8 = EdgeInsets.only(left: 8);
|
||||
static const edgeInsetsL12 = EdgeInsets.only(left: 12);
|
||||
static const edgeInsetsL24 = EdgeInsets.only(left: 24);
|
||||
|
||||
static const edgeInsetsT4 = EdgeInsets.only(top: 4);
|
||||
static const edgeInsetsT8 = EdgeInsets.only(top: 8);
|
||||
static const edgeInsetsT12 = EdgeInsets.only(top: 12);
|
||||
static const edgeInsetsT24 = EdgeInsets.only(top: 24);
|
||||
|
||||
static const edgeInsetsB4 = EdgeInsets.only(bottom: 4);
|
||||
static const edgeInsetsB8 = EdgeInsets.only(bottom: 8);
|
||||
static const edgeInsetsB12 = EdgeInsets.only(bottom: 12);
|
||||
static const edgeInsetsB24 = EdgeInsets.only(bottom: 24);
|
||||
|
||||
static BorderRadius radius4 = BorderRadius.circular(4);
|
||||
static BorderRadius radius8 = BorderRadius.circular(8);
|
||||
static BorderRadius radius12 = BorderRadius.circular(12);
|
||||
static BorderRadius radius24 = BorderRadius.circular(24);
|
||||
static BorderRadius radius32 = BorderRadius.circular(32);
|
||||
static BorderRadius radius48 = BorderRadius.circular(48);
|
||||
|
||||
/// 顶部状态栏的高度
|
||||
static double get statusBarHeight => MediaQuery.of(Get.context!).padding.top;
|
||||
|
||||
/// 底部导航条的高度
|
||||
static double get bottomBarHeight =>
|
||||
MediaQuery.of(Get.context!).padding.bottom;
|
||||
}
|
||||
Reference in New Issue
Block a user