diff --git a/.gitignore b/.gitignore index 9d532b1..48246c2 100644 --- a/.gitignore +++ b/.gitignore @@ -39,3 +39,4 @@ app.*.symbols # Obfuscation related app.*.map.json +resource.dart diff --git a/README.md b/README.md index 447971f..dac408b 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,4 @@ A new Flutter application. ## Getting Started -This project is a starting point for a Flutter application. - -A few resources to get you started if this is your first Flutter project: - -- [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) -- [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) - -For help getting started with Flutter, view our -[online documentation](https://flutter.dev/docs), which offers tutorials, -samples, guidance on mobile development, and a full API reference. +### 使用`fgen`生成图片 diff --git a/assets/fonts/BebasNeue-Regular.ttf b/assets/fonts/BebasNeue-Regular.ttf new file mode 100644 index 0000000..83a29bf Binary files /dev/null and b/assets/fonts/BebasNeue-Regular.ttf differ diff --git a/assets/home/ic_news.png b/assets/home/ic_news.png new file mode 100644 index 0000000..2709f12 Binary files /dev/null and b/assets/home/ic_news.png differ diff --git a/assets/home/ic_scan.png b/assets/home/ic_scan.png new file mode 100644 index 0000000..5d2937c Binary files /dev/null and b/assets/home/ic_scan.png differ diff --git a/assets/home/ic_search.png b/assets/home/ic_search.png new file mode 100644 index 0000000..91ec233 Binary files /dev/null and b/assets/home/ic_search.png differ diff --git a/assets/user/ic_kefu.png b/assets/user/ic_kefu.png new file mode 100644 index 0000000..a53514a Binary files /dev/null and b/assets/user/ic_kefu.png differ diff --git a/assets/user/ic_person.png b/assets/user/ic_person.png new file mode 100644 index 0000000..4ddd834 Binary files /dev/null and b/assets/user/ic_person.png differ diff --git a/assets/user/ic_setup.png b/assets/user/ic_setup.png new file mode 100644 index 0000000..efe8dc2 Binary files /dev/null and b/assets/user/ic_setup.png differ diff --git a/lib/mock_models/users/user_info_model.dart b/lib/mock_models/users/user_info_model.dart new file mode 100644 index 0000000..945e711 --- /dev/null +++ b/lib/mock_models/users/user_info_model.dart @@ -0,0 +1,4 @@ +class UserInfoModel { + String nickName; + String avatarPath; +} diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 110c511..b29b8a1 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -1,10 +1,18 @@ import 'package:flutter/material.dart'; //登录状态管理 class UserProvider extends ChangeNotifier{ + + bool _isSigned=false; + ///用户是否登陆 get isSigned=>_isSigned; + + ///设置用户登陆 setisSigned (bool state){ _isSigned=state; notifyListeners(); } + + + } \ No newline at end of file diff --git a/lib/ui/home/application/applications_page.dart b/lib/ui/home/application/applications_page.dart new file mode 100644 index 0000000..88d0667 --- /dev/null +++ b/lib/ui/home/application/applications_page.dart @@ -0,0 +1,61 @@ + +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community_manager/tools/screen_tool.dart'; + +class ApplicationPage extends StatefulWidget { + ApplicationPage({Key key}) : super(key: key); + + @override + _ApplicationPageState createState() => _ApplicationPageState(); +} + +class _ApplicationPageState extends State { + @override + Widget build(BuildContext context) { + return AkuScaffold( + appBar: AppBar( + brightness: Brightness.light, + elevation: 0, + backgroundColor: Colors.white, + leading: SizedBox( + width: 89.w, + child: AkuBackButton(), + ), + titleSpacing: 0, + title: Container( + margin: EdgeInsets.only(right: 37.w), + padding: EdgeInsets.symmetric(horizontal: 32.w), + height: 72.w, + child: Row( + children: [ + Image.asset( + R.ASSETS_HOME_IC_SEARCH_PNG, + height: 40.w, + width: 40.w, + ), + AkuBox.w(16), + Text( + '搜索应用', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 28.sp, + ), + ), + ], + ), + decoration: BoxDecoration( + color: Color(0xFFF9F9F9), + borderRadius: BorderRadius.circular(8.w), + ), + ), + ), + body: Column( + children: [], + ), + ); + } +} diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 3b9360a..b7b0b25 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -1,13 +1,16 @@ + import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; import 'package:aku_community_manager/ui/home/messages/message.dart'; +import 'package:aku_community_manager/ui/home/application/applications_page.dart'; import 'package:aku_community_manager/ui/home/personal_draw.dart'; import 'package:aku_community_manager/ui/tool_pages/scan_page.dart'; import 'package:aku_ui/aku_ui.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:provider/provider.dart'; @@ -19,374 +22,402 @@ class HomePage extends StatefulWidget { _HomePageState createState() => _HomePageState(); } -//自定义bar的菜单按钮 -Widget _menuButton(IconData iconData, String text, Widget page) { - return AkuButton( - height: 75.w + 8.w + 33.w, - onPressed: () { - Get.to(page); - }, - child: Column( - children: [ - Icon( - iconData, - size: 75.w, - ), - SizedBox(height: 8.w), - Text( - text, - style: TextStyle( - color: Color(0xFF4A4B51), - fontSize: 24.sp, - fontWeight: FontWeight.bold, - ), - ) - ], - ), - ); -} - -//底部信息栏卡片 -Widget _card(String number, String text, Color color) { - return AkuButton( - onPressed: () {}, - color: Color(0xFFFFFFFF), - child: Container( - width: 342.5.w, - height: 166.w, - alignment: Alignment.center, +class _HomePageState extends State { + //自定义bar的菜单按钮 + Widget _menuButton(IconData iconData, String text, Widget page) { + return Expanded( + child: AkuButton( + radius: 8.w, + height: 75.w + 8.w + 33.w, + onPressed: () { + Get.to(page); + }, child: Column( + mainAxisAlignment: MainAxisAlignment.center, children: [ - SizedBox( - height: 32.w, + Icon( + iconData, + size: 75.w, ), + SizedBox(height: 8.w), Text( - number, + text, style: TextStyle( - color: color, fontSize: 40.sp, fontStyle: FontStyle.italic), - ), - SizedBox( - height: 16.w, - ), - Text(text, - style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 24.sp, - fontWeight: FontWeight.bold)), - Spacer(), + color: Color(0xFF4A4B51), + fontSize: 24.sp, + fontWeight: FontWeight.bold, + ), + ) ], - )), - ); -} + ), + ), + ); + } + +//底部信息栏卡片 + Widget _card(String number, String text, Color color) { + return AkuButton( + radius: 8.w, + onPressed: () {}, + color: Color(0xFFFFFFFF), + child: Container( + width: 342.5.w, + height: 166.w, + alignment: Alignment.center, + child: Column( + children: [ + SizedBox( + height: 32.w, + ), + Text( + number, + style: TextStyle( + color: color, + fontSize: 40.sp, + fontFamily: 'Bebas', + ), + ), + SizedBox( + height: 16.w, + ), + Text(text, + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold)), + Spacer(), + ], + )), + ); + } + + @override + void initState() { + super.initState(); + SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( + statusBarColor: Colors.transparent, + )); + } -class _HomePageState extends State { @override Widget build(BuildContext context) { final userProvider = Provider.of(context); ScreenUtil.init(context, designSize: Size(750, 1334), allowFontScaling: true); - return Scaffold( - drawer: PersonalDraw(), - backgroundColor: Color(0xFFF9F9F9), - //自定义bar - appBar: PreferredSize( - preferredSize: Size(375.w, 430.w - 40.w + statusBarHeight), - child: Container( - height: 430.w - 40.w + ScreenUtil().statusBarHeight, - width: double.infinity, - decoration: BoxDecoration( - gradient: LinearGradient( - begin: Alignment.topCenter, - end: Alignment.bottomCenter, - colors: [ - Color(0xFFFFDC6F), - Color(0xFFFFC40C), - ], + return AnnotatedRegion( + child: Scaffold( + drawer: PersonalDraw(), + backgroundColor: Color(0xFFF9F9F9), + //自定义bar + appBar: PreferredSize( + preferredSize: Size(375.w, 430.w - 40.w + statusBarHeight), + child: Container( + height: 430.w - 40.w + ScreenUtil().statusBarHeight, + width: double.infinity, + decoration: BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topCenter, + end: Alignment.bottomCenter, + colors: [ + Color(0xFFFFDC6F), + Color(0xFFFFC40C), + ], + ), + borderRadius: + BorderRadius.only(bottomRight: Radius.circular(32.w)), ), - borderRadius: BorderRadius.only(bottomRight: Radius.circular(32.w)), - ), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - SizedBox(height: ScreenUtil().statusBarHeight), - Container( - height: 88.w, - child: Row(children: [ - SizedBox( - width: 16.w, - ), - Container( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + SizedBox(height: ScreenUtil().statusBarHeight), + Container( + height: 88.w, + child: Row(children: [ + SizedBox( + width: 16.w, + ), + Container( margin: EdgeInsets.only(top: 8.w, bottom: 8.w), width: 72.w, height: 72.w, //头像按钮 - child: Builder(builder: (BuildContext context) { - return AkuRoundButton( - height: 72.w, - onPressed: () { - Scaffold.of(context).openDrawer(); - }, - child: CircleAvatar( - radius: 36.w, - backgroundColor: Colors.grey, - child: userProvider.isSigned ? null : null, + child: Builder( + builder: (BuildContext context) { + return GestureDetector( + onTap: () { + Scaffold.of(context).openDrawer(); + }, + child: CircleAvatar( + radius: 36.w, + backgroundColor: Colors.grey, + child: userProvider.isSigned ? null : null, + ), + ); + }, + ), + ), + SizedBox(width: 16.w), + Expanded( + child: Container( + margin: EdgeInsets.only(top: 8.w, bottom: 8.w), + alignment: Alignment.center, + height: 72.w, + child: AkuButton( + //搜索框按钮 + color: Color(0xFFFFFFFF), + onPressed: () {}, + radius: 8.w, + child: Row(children: [ + Container( + child: Column( + children: [ + SizedBox(height: 18.w), + Icon( + Icons.zoom_in_sharp, + size: 38.w, + ), + ], + ), + ), + SizedBox(width: 19.w), + Text( + '搜索工单订单号、手机', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 28.sp, + ), + ), + ]), + ), + ), + ), + SizedBox(width: 15.w), + Container( + margin: EdgeInsets.only(top: 5.w, bottom: 5.w), + child: MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + //扫一扫按钮 + height: double.infinity, + minWidth: 78.w, + padding: EdgeInsets.zero, + onPressed: () { + Get.to(ScanPage()); + }, + child: Column(children: [ + Image.asset( + R.ASSETS_HOME_IC_SCAN_PNG, + height: 48.w, + width: 48.w, ), - ); - })), - SizedBox(width: 16.w), - Expanded( - child: Container( - margin: EdgeInsets.only(top: 8.w, bottom: 8.w), - alignment: Alignment.center, - height: 72.w, - padding: EdgeInsets.only(left: 21.w), - child: AkuButton( - //搜索框按钮 - color: Color(0xFFFFFFFF), - onPressed: () {}, - child: Row(children: [ - Container( - child: Column( - children: [ - SizedBox(height: 18.w), - Icon( - Icons.zoom_in_sharp, - size: 38.w, - ), - ], + Text( + '扫一扫', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 20.sp, + fontWeight: FontWeight.normal, ), ), - SizedBox(width: 19.w), + ]), + ), + ), + Container( + margin: EdgeInsets.only(top: 5.w, bottom: 5.w), + child: AkuMaterialButton( + minWidth: 78.w, + //消息按钮 + height: double.infinity, + onPressed: () {}, + child: Column(children: [ + Image.asset( + R.ASSETS_HOME_IC_NEWS_PNG, + height: 48.w, + width: 48.w, + ), Text( - '搜索工单订单号、手机', + '消息', style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 28.sp, + color: AppStyle.primaryTextColor, + fontSize: 20.sp, ), ), ]), ), ), + SizedBox(width: 17.w), + ]), + ), + SizedBox(height: 24.w), + Container( + margin: EdgeInsets.only( + left: 32.w, ), - SizedBox(width: 15.w), - Container( - margin: EdgeInsets.only(top: 5.w, bottom: 5.w), - child: MaterialButton( - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - //扫一扫按钮 - height: double.infinity, - minWidth: 78.w, - padding: EdgeInsets.zero, - onPressed: () { - Get.to(ScanPage()); - }, - child: Column(children: [ - Icon( - Icons.access_alarm, - size: 48.w, - ), - Text( - '扫一扫', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 20.sp, - fontWeight: FontWeight.normal, - ), - ), - ]), + height: 67.w, + child: Text( + 'HI,李大海', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 48.sp), + ), + ), + SizedBox(height: 16.w), + Container( + margin: EdgeInsets.only(left: 32.w, right: 32.w), + width: double.infinity, + height: 163.w, + decoration: BoxDecoration( + color: Color(0xFFFFFFFF), + borderRadius: BorderRadius.circular(8.w), + ), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + _menuButton(Icons.wysiwyg, '一键报警', HomePage()), + _menuButton(Icons.work, '访客管理', HomePage()), + _menuButton(Icons.accessibility, '报事报修', HomePage()), + _menuButton( + Icons.account_balance, '全部应用', ApplicationPage()), + ], + ), + ), + ], + ), + ), + ), + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + Container( + //公告标题行 + width: double.infinity, + height: 45.w, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + '今日公告', + style: TextStyle( + color: Color(0xFF4A4B51), + fontSize: 32.sp, + fontWeight: FontWeight.bold, ), ), - Container( - margin: EdgeInsets.only(top: 5.w, bottom: 5.w), - child: AkuMaterialButton( - minWidth: 78.w, - //消息按钮 - height: double.infinity, - onPressed: () { - Get.to(Message()); - }, - child: Column(children: [ - Icon( - Icons.access_time, - size: 48.w, - ), + Spacer(), + AkuButton( + //全部公告按钮 + onPressed: () {}, + child: Row( + children: [ Text( - '消息', + '全部公告', style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 20.sp, + color: AppStyle.minorTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold, ), ), - ]), + Icon( + Icons.arrow_forward_ios, + size: 22.w, + color: AppStyle.minorTextColor, + ) + ], ), ), - SizedBox(width: 17.w), - ]), + ], ), - SizedBox(height: 24.w), - Container( - margin: EdgeInsets.only( - left: 32.w, - ), - height: 67.w, - child: Text( - 'HI,李大海', - style: TextStyle( - color: AppStyle.primaryTextColor, + ), + SizedBox(height: 16.w), + //公告栏 + Container( + color: Color(0xFFFFFFFF), + //公告栏 + width: double.infinity, + height: 172.w, + //TODO listview + ), + SizedBox(height: 32.w), + //待办事项标题行 + Container( + width: double.infinity, + height: 45.w, + child: Row( + children: [ + Text( + '待办事项', + style: TextStyle( + color: Color(0xFF4A4B51), + fontSize: 32.sp, fontWeight: FontWeight.bold, - fontSize: 48.sp), - ), - ), - SizedBox(height: 16.w), - Container( - margin: EdgeInsets.only(left: 32.w, right: 32.w), - padding: EdgeInsets.only(top: 24.w), - color: Color(0xFFFFFFFF), - width: double.infinity, - height: 163.w, - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - _menuButton(Icons.wysiwyg, '一键报警', HomePage()), - _menuButton(Icons.work, '访客管理', HomePage()), - _menuButton(Icons.accessibility, '报事报修', HomePage()), - _menuButton(Icons.account_balance, '全部应用', HomePage()), - ], - ), - ), - ], - ), - ), - ), - body: ListView( - padding: EdgeInsets.all(32.w), - children: [ - Container( - //公告标题行 - width: double.infinity, - height: 45.w, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - '今日公告', - style: TextStyle( - color: Color(0xFF4A4B51), - fontSize: 32.sp, - fontWeight: FontWeight.bold, + ), ), - ), - Spacer(), - AkuButton( - //全部公告按钮 - onPressed: () {}, - child: Row( - children: [ - Text( - '全部公告', - style: TextStyle( + Spacer(), + AkuButton( + onPressed: () {}, + child: Row( + children: [ + Text( + '全部事项', + style: TextStyle( + color: AppStyle.minorTextColor, + fontSize: 24.sp, + fontWeight: FontWeight.bold), + ), + Icon( + Icons.arrow_forward_ios, + size: 22.w, color: AppStyle.minorTextColor, - fontSize: 24.sp, - fontWeight: FontWeight.bold, ), - ), - Icon( - Icons.arrow_forward_ios, - size: 22.w, - color: AppStyle.minorTextColor, - ) - ], + ], + ), ), - ), - ], + ], + ), ), - ), - SizedBox(height: 16.w), - //公告栏 - Container( - color: Color(0xFFFFFFFF), - //公告栏 - width: double.infinity, - height: 172.w, - //TODO listview - ), - SizedBox(height: 32.w), - //待办事项标题行 - Container( - width: double.infinity, - height: 45.w, - child: Row( - children: [ - Text( - '待办事项', - style: TextStyle( - color: Color(0xFF4A4B51), - fontSize: 32.sp, - fontWeight: FontWeight.bold, + SizedBox(height: 16.w), + //待办事项栏 + Container( + width: double.infinity, + height: 449.w, + //TODO listview + ), + SizedBox(height: 24.w), + //底部信息栏 + Container( + width: double.infinity, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.w), + color: Colors.white, + ), + child: Column( + children: [ + Row( + children: [ + _card('25', '未处理事项', Color(0xFFFF4E0D)), + AkuDiveder().verticalDivider(166.5.w), + _card('22', '处理中事项', Color(0xFFFFC40C)), + ], ), - ), - Spacer(), - AkuButton( - onPressed: () {}, - child: Row( + Row(children: [ + AkuDiveder().horizontalDivider(343.w), + AkuDiveder(isReverse: true).horizontalDivider(343.w) + ]), + Row( children: [ - Text( - '全部事项', - style: TextStyle( - color: AppStyle.minorTextColor, - fontSize: 24.sp, - fontWeight: FontWeight.bold), - ), - Icon( - Icons.arrow_forward_ios, - size: 22.w, - color: AppStyle.minorTextColor, + _card('25', '已处理事项', Color(0xFF3F8FFE)), + AkuDiveder(isReverse: true).verticalDivider( + 166.5.w, ), + _card('72', '全部事项', Color(0xFF333333)), ], ), - ), - ], - ), - ), - SizedBox(height: 16.w), - //待办事项栏 - Container( - width: double.infinity, - height: 449.w, - //TODO listview - ), - SizedBox(height: 24.w), - //底部信息栏 - Container( - width: double.infinity, - // height: 333.w, - child: Column( - children: [ - Row( - children: [ - _card('25', '未处理事项', Color(0xFFFF4E0D)), - AkuDiveder().verticalDivider(166.5.w), - _card('22', '处理中事项', Color(0xFFFFC40C)), - ], - ), - Row(children: [ - AkuDiveder().horizontalDivider(343.w), - AkuDiveder(isReverse: true).horizontalDivider(343.w) - ]), - Row( - children: [ - _card('25', '已处理事项', Color(0xFF3F8FFE)), - AkuDiveder(isReverse: true).verticalDivider( - 166.5.w, - ), - _card('72', '全部事项', Color(0xFF333333)), - ], - ), - ], + ], + ), ), - ), - ], + ], + ), ), + value: SystemUiOverlayStyle.dark, ); } } diff --git a/lib/ui/home/personal_draw.dart b/lib/ui/home/personal_draw.dart index 3bb7a89..7901b38 100644 --- a/lib/ui/home/personal_draw.dart +++ b/lib/ui/home/personal_draw.dart @@ -1,3 +1,4 @@ + import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/ui/login/login_page.dart'; @@ -18,27 +19,30 @@ class PersonalDraw extends StatefulWidget { } class _PersonalDrawState extends State { - Widget _myListTile(IconData iconData, String text, {VoidCallback onPressed}) { + Widget _myListTile(String path, String text, {VoidCallback onPressed}) { return AkuButton( onPressed: onPressed, child: Container( - width: double.infinity, height: 96.w, - padding: EdgeInsets.only(left: 32.w, top: 28.w, bottom: 28.w), - child: Row(children: [ - Icon( - iconData, - size: 40.w, - ), - SizedBox(width: 16.w), - Text( - text, - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, + padding: EdgeInsets.only(left: 32.w), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + Image.asset( + path, + width: 40.w, + height: 40.w, + ), + SizedBox(width: 16.w), + Text( + text, + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + ), ), - ), - ]), + ], + ), ), ); } @@ -46,83 +50,86 @@ class _PersonalDrawState extends State { @override Widget build(BuildContext context) { final userProvider = Provider.of(context); - return Drawer( - child: ListView( - children: [ - SizedBox( - height: 80.w - 40.w + ScreenUtil().statusBarHeight, - ), - //leading - Container( - margin: EdgeInsets.only(bottom: 80.w), - width: double.infinity, - child: Row( - children: [ - SizedBox(width: 32.w), - //头像按钮 - AkuRoundButton( - height: 72.w, - onPressed: () {}, - child: CircleAvatar( - radius: 36.w, - backgroundColor: Colors.grey, - child: userProvider.isSigned ? null : null, + return SizedBox( + width: 465.w, + child: Drawer( + child: ListView( + children: [ + SizedBox( + height: 80.w - 40.w + ScreenUtil().statusBarHeight, + ), + //leading + Container( + margin: EdgeInsets.only(bottom: 80.w), + width: double.infinity, + child: Row( + children: [ + SizedBox(width: 32.w), + //头像按钮 + AkuRoundButton( + height: 72.w, + onPressed: () {}, + child: CircleAvatar( + radius: 36.w, + backgroundColor: Colors.grey, + child: userProvider.isSigned ? null : null, + ), ), - ), - SizedBox(width: 24.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - //登录按钮 - InkWell( - onTap: () {}, - child: userProvider.isSigned - ? Text( - '李大海', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold), - ) - : Text('登录', + SizedBox(width: 24.w), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + //登录按钮 + InkWell( + onTap: () {}, + child: userProvider.isSigned + ? Text( + '李大海', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold), + ) + : Text('登录', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 28.sp, + fontWeight: FontWeight.bold)), + ), + InkWell( + onTap: () {}, + child: Row( + children: [ + Icon(Icons.location_on_outlined, size: 33.w), + Text( + '深圳华悦茂峰', style: TextStyle( color: AppStyle.primaryTextColor, - fontSize: 28.sp, - fontWeight: FontWeight.bold)), - ), - InkWell( - onTap: () {}, - child: Row( - children: [ - Icon(Icons.location_on_outlined, size: 33.w), - Text( - '深圳华悦茂峰', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 24.sp), - ), - ], + fontSize: 24.sp), + ), + ], + ), ), - ), - ], - ), - ], + ], + ), + ], + ), + ), + _myListTile( + R.ASSETS_USER_IC_PERSON_PNG, + '个人信息', + onPressed: () { + userProvider.isSigned + ? Get.to(UserInfoPage()) + : Get.to(LoginPage()); + }, ), - ), - _myListTile( - Icons.contact_page, - '个人信息', - onPressed: () { - userProvider.isSigned - ? Get.to(UserInfoPage()) - : Get.to(LoginPage()); - }, - ), - _myListTile(Icons.supervised_user_circle, '联系客服'), - _myListTile(Icons.settings, '设置', onPressed: () { - Get.to(SettingsPage()); - }), - ], + _myListTile(R.ASSETS_USER_IC_KEFU_PNG, '联系客服'), + _myListTile(R.ASSETS_USER_IC_SETUP_PNG, '设置', onPressed: () { + Get.to(SettingsPage()); + }), + ], + ), ), ); } diff --git a/lib/ui/login/login_page.dart b/lib/ui/login/login_page.dart index 5d7fad1..5782e43 100644 --- a/lib/ui/login/login_page.dart +++ b/lib/ui/login/login_page.dart @@ -2,12 +2,16 @@ import 'dart:ui'; import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/login/login_sms_page.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:common_utils/common_utils.dart'; import 'package:extended_text/extended_text.dart'; +import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:aku_community_manager/tools/screen_tool.dart'; +import 'package:get/route_manager.dart'; class LoginPage extends StatefulWidget { LoginPage({Key key}) : super(key: key); @@ -17,45 +21,76 @@ class LoginPage extends StatefulWidget { } class _LoginPageState extends State { + TextEditingController _textController = TextEditingController(); + + bool get phoneValid { + return RegexUtil.isMobileSimple(_textController.text); + } + + bool get emptyText { + return TextUtil.isEmpty(_textController.text); + } + + @override + void dispose() { + _textController?.dispose(); + super.dispose(); + } + @override Widget build(BuildContext context) { return AkuScaffold( backgroundColor: Colors.white, leading: AkuBackButton.close(), body: ListView( + padding: EdgeInsets.symmetric( + vertical: 40.w, + horizontal: 32.w, + ), children: [ - Padding( - padding: EdgeInsets.only( - top: 40.w, - bottom: 184.w, - left: 32.w, - ), - child: Text( - '欢迎登录小蜜蜂', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontWeight: FontWeight.bold, - fontSize: 48.sp, - ), + Text( + '欢迎登录小蜜蜂', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 48.sp, ), ), - Padding( - padding: EdgeInsets.symmetric(horizontal: 32.w), - child: Text( - '手机号码', - style: TextStyle( - color: AppStyle.primaryTextColor, - fontSize: 24.sp, - ), + AkuBox.h(184), + Text( + '手机号码', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 24.sp, ), ), Container( - padding: EdgeInsets.symmetric(horizontal: 32.w), width: double.infinity, child: TextField( autofocus: true, + controller: _textController, + onChanged: (text) { + setState(() {}); + }, keyboardType: TextInputType.phone, decoration: InputDecoration( + suffixIconConstraints: BoxConstraints( + minHeight: 0, + minWidth: 0, + ), + suffixIcon: emptyText + ? SizedBox() + : GestureDetector( + onTap: () { + _textController.clear(); + setState(() {}); + }, + child: Icon( + CupertinoIcons.clear_circled_solid, + size: 30.w, + color: Color(0xFF999999), + ), + ), border: UnderlineInputBorder( borderSide: BorderSide( color: Color(0xFFE8E8E8), @@ -75,10 +110,22 @@ class _LoginPageState extends State { Padding( padding: EdgeInsets.symmetric(horizontal: 32.w), child: AkuMaterialButton( - color: AppStyle.minorColor, - onPressed: () {}, + color: AppStyle.primaryColor, + onPressed: phoneValid + ? () => Get.off(LoginSMSPage(phone: _textController.text)) + : null, + nullColor: Color(0xFFFFE67D), radius: 8.w, - child: Text('获取验证码'), + child: Text( + '获取验证码', + style: TextStyle( + color: phoneValid + ? AppStyle.primaryTextColor + : AppStyle.minorTextColor, + fontSize: 32.sp, + fontWeight: FontWeight.bold, + ), + ), ), ), ], diff --git a/lib/ui/login/login_sms_page.dart b/lib/ui/login/login_sms_page.dart new file mode 100644 index 0000000..165ce0e --- /dev/null +++ b/lib/ui/login/login_sms_page.dart @@ -0,0 +1,126 @@ +import 'dart:async'; + +import 'package:aku_community_manager/provider/user_provider.dart'; +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/widget_tool.dart'; +import 'package:aku_community_manager/ui/home/home_page.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_back_button.dart'; +import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart'; +import 'package:aku_ui/common_widgets/aku_material_button.dart'; +import 'package:flutter/material.dart'; +import 'package:aku_community_manager/tools/screen_tool.dart'; +import 'package:get/get.dart'; +import 'package:pin_input_text_field/pin_input_text_field.dart'; +import 'package:provider/provider.dart'; + +class LoginSMSPage extends StatefulWidget { + final String phone; + LoginSMSPage({Key key, this.phone}) : super(key: key); + + @override + _LoginSMSPageState createState() => _LoginSMSPageState(); +} + +class _LoginSMSPageState extends State { + TextEditingController _textEditingController = TextEditingController(); + int _count = 60; + Timer _countTimer; + bool get canResend => _count <= 0; + String get countString { + if (_count <= 0) + return ''; + else + return '$_count\s'; + } + + startTick() { + _count = 60; + _countTimer = Timer.periodic(Duration(seconds: 1), (timer) { + if (_count >= 0) + _count--; + else { + _countTimer?.cancel(); + } + setState(() {}); + }); + } + + @override + void initState() { + super.initState(); + startTick(); + } + + @override + void dispose() { + _textEditingController?.dispose(); + _countTimer?.cancel(); + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return AkuScaffold( + backgroundColor: Colors.white, + leading: AkuBackButton(), + body: ListView( + padding: EdgeInsets.symmetric( + horizontal: 32.w, + vertical: 40.w, + ), + children: [ + Text( + '请输入短信验证码', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontWeight: FontWeight.bold, + fontSize: 48.sp, + ), + ), + AkuBox.h(16), + Text( + '已向${widget.phone}发送了一个验证码', + style: TextStyle( + color: AppStyle.primaryTextColor, + fontSize: 24.sp, + ), + ), + AkuBox.h(160), + PinInputTextField( + controller: _textEditingController, + autoFocus: true, + decoration: UnderlineDecoration( + lineHeight: 1.w, + colorBuilder: FixedColorBuilder(Color(0xFFE8E8E8)), + ), + onChanged: (text) { + final userProvider = + Provider.of(context, listen: false); + if (text == '000000') { + userProvider.setisSigned(true); + Get.offAll(HomePage()); + } + }, + ), + AkuBox.h(40), + Row( + children: [ + AkuMaterialButton( + onPressed: canResend ? () => startTick() : null, + child: Text( + '重新发送 $countString', + style: TextStyle( + color: canResend + ? AppStyle.secondaryColor + : AppStyle.minorTextColor, + fontSize: 28.sp, + ), + ), + ), + ], + ), + ], + ), + ); + } +} diff --git a/lib/ui/widgets/common/aku_scaffold.dart b/lib/ui/widgets/common/aku_scaffold.dart index 613d514..9ab0f07 100644 --- a/lib/ui/widgets/common/aku_scaffold.dart +++ b/lib/ui/widgets/common/aku_scaffold.dart @@ -65,22 +65,23 @@ class _AkuScaffoldState extends State { Widget build(BuildContext context) { return Scaffold( backgroundColor: widget.backgroundColor, - appBar: AppBar( - backgroundColor: widget.appBarColor, - leading: widget.leading ?? AkuBackButton(), - brightness: widget.brightness, - elevation: 0, - centerTitle: true, - title: DefaultTextStyle( - style: widget.titleStyle ?? - TextStyle( - fontWeight: FontWeight.bold, - color: Color(0xFF333333), - fontSize: 36.sp, - ), - child: Text(widget.title ?? ''), - ), - ), + appBar: widget.appBar ?? + AppBar( + backgroundColor: widget.appBarColor, + leading: widget.leading ?? AkuBackButton(), + brightness: widget.brightness, + elevation: 0, + centerTitle: true, + title: DefaultTextStyle( + style: widget.titleStyle ?? + TextStyle( + fontWeight: FontWeight.bold, + color: Color(0xFF333333), + fontSize: 36.sp, + ), + child: Text(widget.title ?? ''), + ), + ), body: widget.body, bottomNavigationBar: widget.bottom, ); diff --git a/pubspec.lock b/pubspec.lock index 3ece33e..bf7f680 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -6,7 +6,7 @@ packages: description: path: "." ref: HEAD - resolved-ref: e57b6920e49f325c041fac955e1f3297dc9f1d09 + resolved-ref: "89d1e665c372461ed87be46c9227377b305050b2" url: "http://test.akuhotel.com:8099/aku_fe/aku_ui.git" source: git version: "0.0.1" @@ -66,6 +66,27 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.15.0-nullsafety.3" + common_utils: + dependency: "direct main" + description: + name: common_utils + url: "https://pub.flutter-io.cn" + source: hosted + version: "1.2.1" + convert: + dependency: transitive + description: + name: convert + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.1" + crypto: + dependency: transitive + description: + name: crypto + url: "https://pub.flutter-io.cn" + source: hosted + version: "2.1.5" cupertino_icons: dependency: "direct main" description: @@ -73,6 +94,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.0.0" + decimal: + dependency: transitive + description: + name: decimal + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.5" extended_text: dependency: "direct main" description: @@ -153,6 +181,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "1.8.0-nullsafety.1" + pin_input_text_field: + dependency: "direct main" + description: + name: pin_input_text_field + url: "https://pub.flutter-io.cn" + source: hosted + version: "3.1.1" provider: dependency: "direct main" description: @@ -167,6 +202,13 @@ packages: url: "https://pub.flutter-io.cn" source: hosted version: "0.0.13" + rational: + dependency: transitive + description: + name: rational + url: "https://pub.flutter-io.cn" + source: hosted + version: "0.3.8" sky_engine: dependency: transitive description: flutter diff --git a/pubspec.yaml b/pubspec.yaml index 0248e80..d441c23 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -44,6 +44,10 @@ dependencies: extended_text: ^4.0.0 + common_utils: ^1.2.1 + #验证码 + pin_input_text_field: ^3.1.1 + aku_ui: git: url: http://test.akuhotel.com:8099/aku_fe/aku_ui.git @@ -61,6 +65,10 @@ flutter: # included with your application, so that you can use the icons in # the material Icons class. uses-material-design: true + assets: + - assets/ + - assets/home/ + - assets/user/ # To add assets to your application, add an assets section, like this: # assets: # - images/a_dot_burr.jpeg @@ -74,12 +82,10 @@ flutter: # "family" key with the font family name, and a "fonts" key with a # list giving the asset and other descriptors for the font. For # example: - # fonts: - # - family: Schyler - # fonts: - # - asset: fonts/Schyler-Regular.ttf - # - asset: fonts/Schyler-Italic.ttf - # style: italic + fonts: + - family: Bebas + fonts: + - asset: assets/fonts/BebasNeue-Regular.ttf # - family: Trajan Pro # fonts: # - asset: fonts/TrajanPro.ttf