Commit 1aac69f7 authored by laishanqi's avatar laishanqi

修改颜色使用方式,增加扩展方法,扩展了长度单位的使用方法

parent f1aa7572
import 'package:flutter/material.dart';
/// 项目颜色配置 /// 项目颜色配置
class AppColors{ class AppColors{
/// 标题背景颜色 /// 标题背景颜色
static const titleBackgroundColor = 0xffffffff; static const titleBackgroundColor = Color(0xffffffff);
/// 主色 /// 主色
static const mainColor = 0xff2893FF; static const mainColor = Color(0xff2893FF);
/// hint颜色 /// hint颜色
static const hintText = 0xffb4b4b4; static const hintText = Color(0xffb4b4b4);
/// 输入框字体颜色 /// 输入框字体颜色
static const EditTextColor = 0xff333333; static const EditTextColor = Color(0xff333333);
static const color_999 = 0xff999999; static const color_999 = Color(0xff999999);
/// 页面背景颜色 /// 页面背景颜色
static const scaffoldBackgroundColor = 0xffffffff; static const scaffoldBackgroundColor = Color(0xffffffff);
/// 分割线颜色 /// 分割线颜色
static const dividerColor = 0xffeeeeee; static const dividerColor = Color(0xffeeeeee);
/// 控件禁用时的颜色 /// 控件禁用时的颜色
static const disabledColor = 0xffdddddd; static const disabledColor = Color(0xffdddddd);
static const blue_bg_color = 0xFF2893FF; static const blue_bg_color = Color(0xFF2893FF);
static const blue_bg_color2 = 0xFFEEF9FF; static const blue_bg_color2 = Color(0xFFEEF9FF);
static const text_default_color = 0xff666666; static const text_default_color = Color(0xff666666);
static const white_transparent_50 = 0x8CFFFFFF; static const white_transparent_50 = Color(0x8CFFFFFF);
} }
\ No newline at end of file
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
extension IntValue on int{
/// 返回根据屏幕宽高适配后尺寸(单位 dp or pt)
double dp(){
return toDouble().dp();
}
/// 返回间距,应用于四个位置:top,bottom,left,right
EdgeInsets spacingAll(){
return EdgeInsets.all(dp());
}
EdgeInsets spacingLeft(){
return EdgeInsets.only(left: dp());
}
EdgeInsets spacingRight(){
return EdgeInsets.only(right: dp());
}
EdgeInsets spacingTop(){
return EdgeInsets.only(top: dp());
}
EdgeInsets spacingBottom(){
return EdgeInsets.only(bottom: dp());
}
EdgeInsets spacingVertical(){
return EdgeInsets.symmetric(vertical: dp());
}
EdgeInsets spacingHorizontal(){
return EdgeInsets.symmetric(horizontal: dp());
}
}
extension DoubleValue on double{
/// 返回根据屏幕宽高适配后尺寸(单位 dp or pt)
double dp(){
return ScreenUtil.getInstance().getAdapterSize(this);
}
EdgeInsets spacingAll(){
return EdgeInsets.all(dp());
}
EdgeInsets spacingLeft(){
return EdgeInsets.only(left: dp());
}
EdgeInsets spacingRight(){
return EdgeInsets.only(right: dp());
}
EdgeInsets spacingTop(){
return EdgeInsets.only(top: dp());
}
EdgeInsets spacingBottom(){
return EdgeInsets.only(bottom: dp());
}
EdgeInsets spacingVertical(){
return EdgeInsets.symmetric(vertical: dp());
}
EdgeInsets spacingHorizontal(){
return EdgeInsets.symmetric(horizontal: dp());
}
}
...@@ -137,7 +137,7 @@ class _LayoutGroupState extends State<LayoutPage> { ...@@ -137,7 +137,7 @@ class _LayoutGroupState extends State<LayoutPage> {
), ),
), ),
FractionallySizedBox( FractionallySizedBox(
widthFactor: 0.5, widthFactor: 1,
child: Container( child: Container(
decoration: BoxDecoration(color: Colors.grey), decoration: BoxDecoration(color: Colors.grey),
child: Text('屏幕的二分之一'), child: Text('屏幕的二分之一'),
......
...@@ -30,8 +30,8 @@ class _doctorMainPageState extends State<doctorMainPage> { ...@@ -30,8 +30,8 @@ class _doctorMainPageState extends State<doctorMainPage> {
height: 50, height: 50,
child: BottomNavigationBar( child: BottomNavigationBar(
backgroundColor: Colors.white, backgroundColor: Colors.white,
selectedItemColor: Color(AppColors.mainColor), selectedItemColor: AppColors.mainColor,
unselectedItemColor: Color(AppColors.hintText), unselectedItemColor: AppColors.hintText,
selectedFontSize: 10, selectedFontSize: 10,
unselectedFontSize: 10, unselectedFontSize: 10,
currentIndex: currentIndex, currentIndex: currentIndex,
......
import 'package:flutter/material.dart';
import 'package:netrain_flutter_app/common/Ext.dart';
class PharmacyPage extends StatefulWidget {
@override
_PharmacyPageState createState() {
return _PharmacyPageState();
}
}
class _PharmacyPageState extends State<PharmacyPage> {
@override
void initState() {
super.initState();
}
@override
void dispose() {
super.dispose();
}
@override
Widget build(BuildContext context) {
// TODO: implement build
return null;
}
}
\ No newline at end of file
...@@ -95,7 +95,7 @@ class _RegisterState extends State { ...@@ -95,7 +95,7 @@ class _RegisterState extends State {
Text( Text(
"密码由9-16位大小写字母、数字加特殊符号组成", "密码由9-16位大小写字母、数字加特殊符号组成",
style: style:
TextStyle(color: Color(AppColors.mainColor), fontSize: 12), TextStyle(color: AppColors.mainColor, fontSize: 12),
), ),
Container( Container(
margin: EdgeInsets.only(top: 20), margin: EdgeInsets.only(top: 20),
...@@ -105,9 +105,9 @@ class _RegisterState extends State { ...@@ -105,9 +105,9 @@ class _RegisterState extends State {
backgroundColor: backgroundColor:
MaterialStateProperty.resolveWith((states) { MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) { if (states.contains(MaterialState.disabled)) {
return Color(AppColors.disabledColor); return AppColors.disabledColor;
} }
return Color(AppColors.mainColor); return AppColors.mainColor;
}), }),
), ),
child: Text( child: Text(
...@@ -203,11 +203,11 @@ class _RegisterState extends State { ...@@ -203,11 +203,11 @@ class _RegisterState extends State {
enabledBorder: UnderlineInputBorder( enabledBorder: UnderlineInputBorder(
// 默认状态的下划线边框 // 默认状态的下划线边框
borderSide: borderSide:
BorderSide(color: Color(AppColors.dividerColor), width: 0.5)), BorderSide(color: AppColors.dividerColor, width: 0.5)),
focusedBorder: UnderlineInputBorder( focusedBorder: UnderlineInputBorder(
// 输入框获取焦点后 // 输入框获取焦点后
borderSide: borderSide:
BorderSide(color: Color(AppColors.mainColor), width: 0.5)), BorderSide(color: AppColors.mainColor, width: 0.5)),
errorBorder: UnderlineInputBorder( errorBorder: UnderlineInputBorder(
// 错误的时候 // 错误的时候
borderSide: BorderSide(color: Colors.red, width: 0.5)), borderSide: BorderSide(color: Colors.red, width: 0.5)),
......
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
...@@ -38,6 +39,7 @@ class MyApp extends StatelessWidget { ...@@ -38,6 +39,7 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application. // This widget is the root of your application.
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
setDesignWHD(375, 812);
// 设置状态栏为透明 // 设置状态栏为透明
SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle systemUiOverlayStyle =
SystemUiOverlayStyle(statusBarColor: Colors.transparent); SystemUiOverlayStyle(statusBarColor: Colors.transparent);
...@@ -48,11 +50,11 @@ class MyApp extends StatelessWidget { ...@@ -48,11 +50,11 @@ class MyApp extends StatelessWidget {
title: 'Flutter Demo', title: 'Flutter Demo',
initialRoute: "main", initialRoute: "main",
theme: ThemeData( theme: ThemeData(
primaryColor: Color(AppColors.titleBackgroundColor), primaryColor: AppColors.titleBackgroundColor,
hintColor: Color(AppColors.hintText), hintColor: AppColors.hintText,
accentColor: Color(AppColors.mainColor), accentColor: AppColors.mainColor,
dividerColor: Color(AppColors.dividerColor), dividerColor: AppColors.dividerColor,
scaffoldBackgroundColor: Color(AppColors.scaffoldBackgroundColor), scaffoldBackgroundColor: AppColors.scaffoldBackgroundColor,
visualDensity: VisualDensity.adaptivePlatformDensity, visualDensity: VisualDensity.adaptivePlatformDensity,
), ),
localizationsDelegates: [ localizationsDelegates: [
......
...@@ -80,7 +80,7 @@ class _HomePageState extends State<HomePage> { ...@@ -80,7 +80,7 @@ class _HomePageState extends State<HomePage> {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
elevation: 0, elevation: 0,
backgroundColor: Color(AppColors.blue_bg_color), backgroundColor: (AppColors.blue_bg_color),
title: Text( title: Text(
"基本信息", "基本信息",
style: TextStyle( style: TextStyle(
...@@ -108,7 +108,7 @@ class _HomePageState extends State<HomePage> { ...@@ -108,7 +108,7 @@ class _HomePageState extends State<HomePage> {
body: new Column(children: [ body: new Column(children: [
Container( Container(
height: 80, height: 80,
color: Color(AppColors.blue_bg_color), color: (AppColors.blue_bg_color),
child: Column( child: Column(
children: [ children: [
Spacer(), Spacer(),
...@@ -122,7 +122,7 @@ class _HomePageState extends State<HomePage> { ...@@ -122,7 +122,7 @@ class _HomePageState extends State<HomePage> {
width: 22, width: 22,
child: Text( child: Text(
"1", "1",
style: TextStyle(color: Color(AppColors.blue_bg_color)), style: TextStyle(color: (AppColors.blue_bg_color)),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0), borderRadius: BorderRadius.circular(11.0),
...@@ -136,11 +136,11 @@ class _HomePageState extends State<HomePage> { ...@@ -136,11 +136,11 @@ class _HomePageState extends State<HomePage> {
width: 22, width: 22,
child: Text( child: Text(
"2", "2",
style: TextStyle(color: Color(AppColors.blue_bg_color)), style: TextStyle(color: (AppColors.blue_bg_color)),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0), borderRadius: BorderRadius.circular(11.0),
color: Color(AppColors.white_transparent_50), color: (AppColors.white_transparent_50),
), ),
), ),
Spacer(), Spacer(),
...@@ -150,11 +150,11 @@ class _HomePageState extends State<HomePage> { ...@@ -150,11 +150,11 @@ class _HomePageState extends State<HomePage> {
width: 22, width: 22,
child: Text( child: Text(
"3", "3",
style: TextStyle(color: Color(AppColors.blue_bg_color)), style: TextStyle(color: (AppColors.blue_bg_color)),
), ),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0), borderRadius: BorderRadius.circular(11.0),
color: Color(AppColors.white_transparent_50), color: (AppColors.white_transparent_50),
), ),
), ),
SizedBox(width: 54), SizedBox(width: 54),
...@@ -173,14 +173,14 @@ class _HomePageState extends State<HomePage> { ...@@ -173,14 +173,14 @@ class _HomePageState extends State<HomePage> {
Text( Text(
"提交证件", "提交证件",
style: TextStyle( style: TextStyle(
color: Color(AppColors.white_transparent_50), color: (AppColors.white_transparent_50),
fontSize: 12), fontSize: 12),
), ),
Spacer(), Spacer(),
Text( Text(
"审核完毕", "审核完毕",
style: TextStyle( style: TextStyle(
color: Color(AppColors.white_transparent_50), color: (AppColors.white_transparent_50),
fontSize: 12), fontSize: 12),
), ),
SizedBox(width: 41), SizedBox(width: 41),
...@@ -194,7 +194,7 @@ class _HomePageState extends State<HomePage> { ...@@ -194,7 +194,7 @@ class _HomePageState extends State<HomePage> {
margin: EdgeInsets.all(16), margin: EdgeInsets.all(16),
padding: EdgeInsets.fromLTRB(0, 0, 0, 16), padding: EdgeInsets.fromLTRB(0, 0, 0, 16),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Color(AppColors.blue_bg_color2), color: (AppColors.blue_bg_color2),
borderRadius: BorderRadius.circular(4.0), borderRadius: BorderRadius.circular(4.0),
), ),
child: Column( child: Column(
...@@ -203,7 +203,7 @@ class _HomePageState extends State<HomePage> { ...@@ -203,7 +203,7 @@ class _HomePageState extends State<HomePage> {
child: Text( child: Text(
"您完成所有认证资料,并完成互联网医院认证备案后,杏联医生工作室将为您提供以下功能:", "您完成所有认证资料,并完成互联网医院认证备案后,杏联医生工作室将为您提供以下功能:",
style: TextStyle( style: TextStyle(
fontSize: 12, color: Color(AppColors.text_default_color)), fontSize: 12, color: AppColors.text_default_color),
), ),
margin: EdgeInsets.all(10), margin: EdgeInsets.all(10),
), ),
...@@ -220,13 +220,13 @@ class _HomePageState extends State<HomePage> { ...@@ -220,13 +220,13 @@ class _HomePageState extends State<HomePage> {
"邀请患者", "邀请患者",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: Color(AppColors.EditTextColor), color: (AppColors.EditTextColor),
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
Text( Text(
"专属二维码", "专属二维码",
style: TextStyle( style: TextStyle(
color: Color(AppColors.text_default_color), color: (AppColors.text_default_color),
fontSize: 12 fontSize: 12
), ),
) )
...@@ -249,13 +249,13 @@ class _HomePageState extends State<HomePage> { ...@@ -249,13 +249,13 @@ class _HomePageState extends State<HomePage> {
"电子处方权", "电子处方权",
style: TextStyle( style: TextStyle(
fontSize: 16, fontSize: 16,
color: Color(AppColors.EditTextColor), color: AppColors.EditTextColor,
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
Text( Text(
"建立自己的诊室", "建立自己的诊室",
style: TextStyle( style: TextStyle(
color: Color(AppColors.text_default_color), color: AppColors.text_default_color,
fontSize: 12 fontSize: 12
), ),
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment