Commit 1aac69f7 authored by laishanqi's avatar laishanqi

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

parent f1aa7572
import 'package:flutter/material.dart';
/// 项目颜色配置
class AppColors{
/// 标题背景颜色
static const titleBackgroundColor = 0xffffffff;
static const titleBackgroundColor = Color(0xffffffff);
/// 主色
static const mainColor = 0xff2893FF;
static const mainColor = Color(0xff2893FF);
/// hint颜色
static const hintText = 0xffb4b4b4;
static const hintText = Color(0xffb4b4b4);
/// 输入框字体颜色
static const EditTextColor = 0xff333333;
static const color_999 = 0xff999999;
static const EditTextColor = Color(0xff333333);
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> {
),
),
FractionallySizedBox(
widthFactor: 0.5,
widthFactor: 1,
child: Container(
decoration: BoxDecoration(color: Colors.grey),
child: Text('屏幕的二分之一'),
......
......@@ -30,8 +30,8 @@ class _doctorMainPageState extends State<doctorMainPage> {
height: 50,
child: BottomNavigationBar(
backgroundColor: Colors.white,
selectedItemColor: Color(AppColors.mainColor),
unselectedItemColor: Color(AppColors.hintText),
selectedItemColor: AppColors.mainColor,
unselectedItemColor: AppColors.hintText,
selectedFontSize: 10,
unselectedFontSize: 10,
currentIndex: currentIndex,
......
......@@ -3,6 +3,7 @@ import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:netrain_flutter_app/common/AppColors.dart';
import 'package:netrain_flutter_app/common/Images.dart';
import 'package:netrain_flutter_app/common/Ext.dart';
class DoctorHomePage extends StatefulWidget {
@override
......@@ -17,12 +18,11 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
void initState() {
super.initState();
_scrollController.addListener(() {
print("华东 ${_scrollController.offset}");
if (_scrollController.offset > 270 && !isShowBlackTitle) {
if (_scrollController.offset > 302.dp() && !isShowBlackTitle) {
setState(() {
isShowBlackTitle = true;
});
} else if (_scrollController.offset < 270 && isShowBlackTitle) {
} else if (_scrollController.offset < 302.dp() && isShowBlackTitle) {
setState(() {
isShowBlackTitle = false;
});
......@@ -43,41 +43,57 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
controller: _scrollController,
slivers: [
SliverAppBar(
titleSpacing: 16,
toolbarHeight: 50,
titleSpacing: 16.dp(),
toolbarHeight: 50.dp(),
automaticallyImplyLeading: false,
pinned: true,
floating: false,
// snap: true,
stretch: true,
title: Container(
child: Text(
"我的工作站",
style: TextStyle(
fontSize: 21,
fontWeight: FontWeight.bold,
color: isShowBlackTitle ? Colors.black : Colors.white),
),
),
expandedHeight: 352.dp() - ScreenUtil.getStatusBarH(context),
flexibleSpace: FlexibleSpaceBar(
collapseMode: CollapseMode.pin,
// 拉伸的样式
stretchModes: [StretchMode.blurBackground,StretchMode.zoomBackground],
background: Container(
color: Color(AppColors.mainColor),
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xff379BFF), Color(0xff0B7CEE)])),
child: Stack(
children: [
Positioned(
child: ClipOval(
//圆形裁剪
child: Container(
height: 56,
width: 56,
height: 56.dp(),
width: 56.dp(),
constraints:
BoxConstraints(maxHeight: 100, maxWidth: 100),
BoxConstraints(maxHeight: 100.dp(), maxWidth: 100.dp()),
foregroundDecoration: BoxDecoration(
borderRadius: BorderRadius.circular(50),
borderRadius: BorderRadius.circular(50.dp()),
border: Border.all(
color: Colors.white,
width: 2,
width: 2.dp(),
style: BorderStyle.solid)),
child: Image.network(
'http://pix2.tvzhe.com/thumb/star/60/87/260x346.jpg',
height: 56,
width: 56,
height: 56.dp(),
width: 56.dp(),
fit: BoxFit.cover,
),
),
),
top: 106,
left: 18,
top: 106.dp(),
left: 18.dp(),
),
Positioned(
child: Text(
......@@ -87,24 +103,24 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
fontSize: 18,
fontWeight: FontWeight.bold),
),
top: 106,
left: 82,
top: 106.dp(),
left: 82.dp(),
),
Positioned(
child: Text(
"主任医师",
style: TextStyle(color: Colors.white, fontSize: 12),
),
top: 111,
left: 144,
top: 111.dp(),
left: 144.dp(),
),
Positioned(
child: Container(
width: 68,
height: 20,
width: 68.dp(),
height: 20.dp(),
decoration: BoxDecoration(
color: Colors.white30,
borderRadius: BorderRadius.circular(10)),
borderRadius: BorderRadius.circular(10.dp())),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
......@@ -121,27 +137,28 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
],
),
),
top: 138,
left: 82,
top: 138.dp(),
left: 82.dp(),
),
Positioned(
child: Image.asset(
Images.ic_code,
height: 30,
width: 30,
height: 30.dp(),
width: 30.dp(),
),
top: 117,
right: 16,
top: 117.dp(),
right: 16.dp(),
),
Positioned(
child: Container(
child: _getStatisticsView(),
width: ScreenUtil.getScreenW(context),
),
top: 185,
top: 185.dp(),
),
Positioned(
child: Container(
padding: EdgeInsets.only(left: 8.dp(),right: 8.dp()),
child: Flex(
direction: Axis.horizontal,
children: [
......@@ -151,37 +168,25 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
),
width: ScreenUtil.getScreenW(context),
),
top: 253,
left: 8,
right: 8,
top: 253.dp(),
),
],
),
),
),
expandedHeight: 322,
title: Container(
child: Text(
"我的工作站",
style: TextStyle(
fontSize: 21,
fontWeight: FontWeight.bold,
color: isShowBlackTitle ? Colors.black : Colors.white),
),
),
),
SliverToBoxAdapter(
child: Container(
margin: EdgeInsets.only(top: 16, bottom: 16),
margin: EdgeInsets.only(top: 16.dp(), bottom: 16.dp()),
child: Wrap(
spacing: 8,
spacing: 8.dp(),
children: [
Image.asset(Images.ic_home_list),
Text(
"咨询列表",
textAlign: TextAlign.center,
style: TextStyle(
color: Color(AppColors.EditTextColor),
color: AppColors.EditTextColor,
fontSize: 18,
fontWeight: FontWeight.bold),
),
......@@ -208,7 +213,7 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
return Dismissible(
background: Container(
alignment: Alignment.centerRight,
padding: EdgeInsets.only(right: 16),
padding: EdgeInsets.only(right: 16.dp()),
color: Colors.red,
child: Text(
"删除",
......@@ -227,28 +232,28 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
},
child: Container(
width: ScreenUtil.getScreenW(context),
height: 82,
height: 82.dp(),
child: Stack(
children: [
Positioned(
child: Image.asset(
Images.ic_doctor_avatar,
width: 50,
height: 50,
width: 50.dp(),
height: 50.dp(),
),
top: 16,
left: 5,
top: 16.dp(),
left: 5.dp(),
),
Positioned(
child: Text(
"${list[index]}",
style: TextStyle(
color: Color(AppColors.EditTextColor),
color: AppColors.EditTextColor,
fontWeight: FontWeight.bold,
fontSize: 16),
),
top: 16,
left: 66,
top: 16.dp(),
left: 66.dp(),
),
Positioned(
width: ScreenUtil.getScreenW(context) * 0.7,
......@@ -257,10 +262,10 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(AppColors.color_999), fontSize: 14),
color: AppColors.color_999, fontSize: 14),
),
bottom: 18,
left: 66,
bottom: 18.dp(),
left: 66.dp(),
),
Positioned(
child: Text(
......@@ -268,17 +273,17 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(
color: Color(AppColors.hintText), fontSize: 12),
color: AppColors.hintText, fontSize: 12),
),
top: 16,
right: 16,
top: 16.dp(),
right: 16.dp(),
),
Positioned(
child: Container(
margin: EdgeInsets.only(left: 16, right: 16),
margin: EdgeInsets.only(left: 16.dp(), right: 16.dp()),
width: ScreenUtil.getScreenW(context) - 32,
height: 1,
color: Color(AppColors.dividerColor),
color: AppColors.dividerColor,
),
bottom: 0,
)
......@@ -301,7 +306,7 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
"您暂时没有新消息",
style: TextStyle(
fontSize: 14,
color: Color(AppColors.text_default_color),
color: AppColors.text_default_color,
),
textAlign: TextAlign.center,
)
......@@ -356,7 +361,8 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
return Expanded(
flex: 1,
child: Container(
margin: EdgeInsets.only(left: 8, right: 8),
height: 83.dp(),
margin: 8.spacingHorizontal(),
child: Stack(
children: [
Image.asset(Images.img_home_pharmacy),
......@@ -364,23 +370,23 @@ class _DoctorHomePageState extends State<DoctorHomePage> {
child: Text(
name,
style: TextStyle(
color: Color(AppColors.mainColor),
color: AppColors.mainColor,
fontSize: 14,
fontWeight: FontWeight.bold),
),
top: 10,
left: 10,
top: 10.dp(),
left: 10.dp(),
),
Positioned(
child: Text(
num,
style: TextStyle(
color: Color(AppColors.mainColor),
color: AppColors.mainColor,
fontSize: 36,
fontWeight: FontWeight.bold),
),
bottom: 0,
left: 10,
left: 10.dp(),
),
],
),
......
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 {
Text(
"密码由9-16位大小写字母、数字加特殊符号组成",
style:
TextStyle(color: Color(AppColors.mainColor), fontSize: 12),
TextStyle(color: AppColors.mainColor, fontSize: 12),
),
Container(
margin: EdgeInsets.only(top: 20),
......@@ -105,9 +105,9 @@ class _RegisterState extends State {
backgroundColor:
MaterialStateProperty.resolveWith((states) {
if (states.contains(MaterialState.disabled)) {
return Color(AppColors.disabledColor);
return AppColors.disabledColor;
}
return Color(AppColors.mainColor);
return AppColors.mainColor;
}),
),
child: Text(
......@@ -203,11 +203,11 @@ class _RegisterState extends State {
enabledBorder: UnderlineInputBorder(
// 默认状态的下划线边框
borderSide:
BorderSide(color: Color(AppColors.dividerColor), width: 0.5)),
BorderSide(color: AppColors.dividerColor, width: 0.5)),
focusedBorder: UnderlineInputBorder(
// 输入框获取焦点后
borderSide:
BorderSide(color: Color(AppColors.mainColor), width: 0.5)),
BorderSide(color: AppColors.mainColor, width: 0.5)),
errorBorder: UnderlineInputBorder(
// 错误的时候
borderSide: BorderSide(color: Colors.red, width: 0.5)),
......
import 'package:flustars/flustars.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
......@@ -38,6 +39,7 @@ class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
setDesignWHD(375, 812);
// 设置状态栏为透明
SystemUiOverlayStyle systemUiOverlayStyle =
SystemUiOverlayStyle(statusBarColor: Colors.transparent);
......@@ -48,11 +50,11 @@ class MyApp extends StatelessWidget {
title: 'Flutter Demo',
initialRoute: "main",
theme: ThemeData(
primaryColor: Color(AppColors.titleBackgroundColor),
hintColor: Color(AppColors.hintText),
accentColor: Color(AppColors.mainColor),
dividerColor: Color(AppColors.dividerColor),
scaffoldBackgroundColor: Color(AppColors.scaffoldBackgroundColor),
primaryColor: AppColors.titleBackgroundColor,
hintColor: AppColors.hintText,
accentColor: AppColors.mainColor,
dividerColor: AppColors.dividerColor,
scaffoldBackgroundColor: AppColors.scaffoldBackgroundColor,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
localizationsDelegates: [
......
......@@ -80,7 +80,7 @@ class _HomePageState extends State<HomePage> {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Color(AppColors.blue_bg_color),
backgroundColor: (AppColors.blue_bg_color),
title: Text(
"基本信息",
style: TextStyle(
......@@ -108,7 +108,7 @@ class _HomePageState extends State<HomePage> {
body: new Column(children: [
Container(
height: 80,
color: Color(AppColors.blue_bg_color),
color: (AppColors.blue_bg_color),
child: Column(
children: [
Spacer(),
......@@ -122,7 +122,7 @@ class _HomePageState extends State<HomePage> {
width: 22,
child: Text(
"1",
style: TextStyle(color: Color(AppColors.blue_bg_color)),
style: TextStyle(color: (AppColors.blue_bg_color)),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0),
......@@ -136,11 +136,11 @@ class _HomePageState extends State<HomePage> {
width: 22,
child: Text(
"2",
style: TextStyle(color: Color(AppColors.blue_bg_color)),
style: TextStyle(color: (AppColors.blue_bg_color)),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0),
color: Color(AppColors.white_transparent_50),
color: (AppColors.white_transparent_50),
),
),
Spacer(),
......@@ -150,11 +150,11 @@ class _HomePageState extends State<HomePage> {
width: 22,
child: Text(
"3",
style: TextStyle(color: Color(AppColors.blue_bg_color)),
style: TextStyle(color: (AppColors.blue_bg_color)),
),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(11.0),
color: Color(AppColors.white_transparent_50),
color: (AppColors.white_transparent_50),
),
),
SizedBox(width: 54),
......@@ -173,14 +173,14 @@ class _HomePageState extends State<HomePage> {
Text(
"提交证件",
style: TextStyle(
color: Color(AppColors.white_transparent_50),
color: (AppColors.white_transparent_50),
fontSize: 12),
),
Spacer(),
Text(
"审核完毕",
style: TextStyle(
color: Color(AppColors.white_transparent_50),
color: (AppColors.white_transparent_50),
fontSize: 12),
),
SizedBox(width: 41),
......@@ -194,7 +194,7 @@ class _HomePageState extends State<HomePage> {
margin: EdgeInsets.all(16),
padding: EdgeInsets.fromLTRB(0, 0, 0, 16),
decoration: BoxDecoration(
color: Color(AppColors.blue_bg_color2),
color: (AppColors.blue_bg_color2),
borderRadius: BorderRadius.circular(4.0),
),
child: Column(
......@@ -203,7 +203,7 @@ class _HomePageState extends State<HomePage> {
child: Text(
"您完成所有认证资料,并完成互联网医院认证备案后,杏联医生工作室将为您提供以下功能:",
style: TextStyle(
fontSize: 12, color: Color(AppColors.text_default_color)),
fontSize: 12, color: AppColors.text_default_color),
),
margin: EdgeInsets.all(10),
),
......@@ -220,13 +220,13 @@ class _HomePageState extends State<HomePage> {
"邀请患者",
style: TextStyle(
fontSize: 16,
color: Color(AppColors.EditTextColor),
color: (AppColors.EditTextColor),
fontWeight: FontWeight.bold),
),
Text(
"专属二维码",
style: TextStyle(
color: Color(AppColors.text_default_color),
color: (AppColors.text_default_color),
fontSize: 12
),
)
......@@ -249,13 +249,13 @@ class _HomePageState extends State<HomePage> {
"电子处方权",
style: TextStyle(
fontSize: 16,
color: Color(AppColors.EditTextColor),
color: AppColors.EditTextColor,
fontWeight: FontWeight.bold),
),
Text(
"建立自己的诊室",
style: TextStyle(
color: Color(AppColors.text_default_color),
color: AppColors.text_default_color,
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