diff --git a/lib/pages/home/home_page.dart b/lib/pages/home/home_page.dart index 407a6922..b69ab2b2 100644 --- a/lib/pages/home/home_page.dart +++ b/lib/pages/home/home_page.dart @@ -75,7 +75,7 @@ class _HomePageState extends State }), GridButton('建议咨询', R.ASSETS_ICONS_TOOL_JYTS_PNG, () { Get.to(ThingsPage( - bundle: Bundle() + bundle: Bundle() ..putMap('things', { 'title': '建议咨询', 'treeList': >[ @@ -104,7 +104,6 @@ class _HomePageState extends State }); // akuShop(page); _scrollController = ScrollController(); - } Future akuShop(String response) async { @@ -145,8 +144,6 @@ class _HomePageState extends State ); } - - @override Widget build(BuildContext context) { super.build(context); @@ -156,19 +153,19 @@ class _HomePageState extends State extendBodyBehindAppBar: true, appBar: AnimateAppBar( scrollController: _scrollController, - actions:[ - _buildColButton( - icon: AntDesign.scan1, - title: '扫一扫', - onTap: () => Get.to(ScanPage()), - ), - _buildColButton( - icon: AntDesign.bells, - title: '消息', - onTap: () => Get.to(MessageCenterPage()), - ), - 16.wb, - ], + actions: [ + _buildColButton( + icon: AntDesign.scan1, + title: '扫一扫', + onTap: () => Get.to(ScanPage()), + ), + _buildColButton( + icon: AntDesign.bells, + title: '消息', + onTap: () => Get.to(MessageCenterPage()), + ), + 16.wb, + ], ), body: RefreshConfiguration( child: SmartRefresher( diff --git a/lib/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart b/lib/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart index d77fa7da..154c4735 100644 --- a/lib/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart +++ b/lib/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart @@ -35,7 +35,7 @@ class _CommitteeMailboxPageState extends State { bottom: 0.w, ), hintText: '', - border: InputBorder.none, //去掉输入框的下滑线 + border: InputBorder.none, fillColor: Colors.white, filled: true, hintStyle: TextStyle( diff --git a/lib/pages/industry_committee/industry_committee_page.dart b/lib/pages/industry_committee/industry_committee_page.dart index b8ef62a8..d63a44d4 100644 --- a/lib/pages/industry_committee/industry_committee_page.dart +++ b/lib/pages/industry_committee/industry_committee_page.dart @@ -1,3 +1,4 @@ +import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/pages/industry_committee/committee_mailbox/committee_mailbox_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:flutter/material.dart'; @@ -5,7 +6,7 @@ import 'package:flutter/cupertino.dart'; import 'package:get/get.dart'; import 'package:url_launcher/url_launcher.dart'; import 'package:akuCommunity/utils/headers.dart'; -import 'widget/staff_list.dart'; +import 'package:velocity_x/velocity_x.dart'; class IndustryCommitteePage extends StatefulWidget { IndustryCommitteePage({Key key}) : super(key: key); @@ -15,131 +16,62 @@ class IndustryCommitteePage extends StatefulWidget { } class _IndustryCommitteePageState extends State { - List> _listBottom = [ - { - 'title': '业委会电话', - 'color': Color(0xff2a2a2a), - 'fontColor': Color(0xffffffff), - }, - { - 'title': '业委会信箱', - 'color': Color(0xffffc40c), - 'fontColor': Color(0xff333333), - }, - ]; - Future _phoneCall(String url) async { - if (await canLaunch(url)) { - await launch(url); - } else { - throw 'Could not launch $url'; - } - } - - void _showDialog() { - showCupertinoDialog( - context: context, - builder: (context) { - return CupertinoAlertDialog( - title: Text( - '0574-88478909', - style: TextStyle( - fontSize: 34.sp, - color: Color(0xff030303), - ), - ), - actions: [ - CupertinoDialogAction( - child: Text( - '取消', - style: TextStyle( - fontSize: 34.sp, - color: Color(0xff333333), - ), + Widget _buildBottomNavi() { + return [ + MaterialButton( + onPressed: () { + Get.dialog(CupertinoAlertDialog( + //TODO 业委会电话, for test only + title: '(0574) 8888 8888'.text.isIntrinsic.make(), + actions: [ + CupertinoDialogAction( + child: '取消'.text.isIntrinsic.make(), + onPressed: Get.back, ), - onPressed: () { - Get.back(); - }, - ), - CupertinoDialogAction( - child: Text( - '呼叫', - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 34.sp, - color: Color(0xffff8200), - ), + CupertinoDialogAction( + child: '呼叫'.text.isIntrinsic.orange500.make(), + onPressed: () { + launch('tel:10086'); + Get.back(); + }, ), - onPressed: () { - _phoneCall('tel:${'0574-88478909'}'); - Get.back(); - }, - ), - ], - ); - }, - ); - } - - InkWell _inkWellBotoom(String title, Color color, Color fontColor) { - return InkWell( - onTap: () { - switch (title) { - case '业委会电话': - _showDialog(); - break; - case '业委会信箱': - CommitteeMailboxPage().to; - break; - default: - } - }, - child: Container( - color: color, - alignment: Alignment.center, - padding: EdgeInsets.symmetric( - vertical: 26.5.w, - ), - child: Text( - title, - style: TextStyle( - fontSize: 32.sp, - color: fontColor, - ), - ), - ), - ); - } - - Positioned _positionedBottomBar() { - return Positioned( - bottom: 0, - child: Container( - height: 98.w + MediaQuery.of(context).viewPadding.bottom, - width: MediaQuery.of(context).size.width, - child: Row( - children: _listBottom - .map((item) => Expanded( - child: _inkWellBotoom( - item['title'], - item['color'], - item['fontColor'], - ), - )) - .toList(), - ), - ), - ); + ], + )); + }, + height: 98.w, + color: Color(0xFF2A2A2A), + child: '业委会电话'.text.white.size(32.sp).make(), + ) + .box + .color(Color(0xFF2A2A2A)) + .margin(EdgeInsets.only( + bottom: MediaQuery.of(context).viewPadding.bottom, + )) + .make() + .expand(), + MaterialButton( + onPressed: CommitteeMailboxPage().to, + height: 98.w, + color: kPrimaryColor, + child: '业委会信箱'.text.size(32.sp).color(ktextPrimary).make(), + ) + .box + .color(kPrimaryColor) + .margin(EdgeInsets.only( + bottom: MediaQuery.of(context).viewPadding.bottom, + )) + .make() + .expand(), + ].row(); } Widget build(BuildContext context) { return BeeScaffold( title: '业委会', body: Stack( - children: [ - StaffList(), - _positionedBottomBar(), - ], + children: [], ), + bottomNavi: _buildBottomNavi(), ); } } diff --git a/lib/pages/industry_committee/widget/staff_list.dart b/lib/pages/industry_committee/widget/staff_list.dart deleted file mode 100644 index f8f75634..00000000 --- a/lib/pages/industry_committee/widget/staff_list.dart +++ /dev/null @@ -1,182 +0,0 @@ -import 'package:akuCommunity/utils/headers.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/cupertino.dart'; -import 'package:pull_to_refresh/pull_to_refresh.dart'; -import 'package:akuCommunity/widget/cached_image_wrapper.dart'; - -class StaffList extends StatefulWidget { - StaffList({Key key}) : super(key: key); - - @override - _StaffListState createState() => _StaffListState(); -} - -class _StaffListState extends State { - List> _staffList = [ - { - 'name': '刘鄂', - 'imagePath': - 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=1917253203,3586495528&fm=26&gp=0.jpg', - 'address': '3幢2单元703室', - 'tenure': '2016年12月19日-2020年10月3日', - 'post': '会计师', - 'tag': '主任' - }, - { - 'name': '史红', - 'imagePath': - 'https://ss0.bdstatic.com/70cFuHSh_Q1YnxGkpoWK1HF6hhy/it/u=1051460286,4207974038&fm=26&gp=0.jpg', - 'address': '10幢1单元1903室', - 'tenure': '2017年4月21日-2020年10月3日', - 'post': '宠物医生', - 'tag': '副主任' - }, - { - 'name': '陈吉明', - 'imagePath': - 'https://ss1.bdstatic.com/70cFuXSh_Q1YnxGkpoWK1HF6hhy/it/u=2962135405,1279141756&fm=26&gp=0.jpg', - 'address': '19幢1单元203室', - 'tenure': '2018年12月12日-2020年10月3日', - 'post': '个体私营五金厂老板', - 'tag': '委员' - }, - { - 'name': '周立宇', - 'imagePath': - 'https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=2503876943,2429234388&fm=26&gp=0.jpg', - 'address': '19幢1单元203室', - 'tenure': '2018年11月23日-2020年10月3日', - 'post': '技术工程师', - 'tag': '委员' - }, - ]; - RefreshController _refreshController = - RefreshController(initialRefresh: false); - - void _onRefresh() async { - await Future.delayed(Duration(milliseconds: 1500)); - _refreshController.refreshCompleted(); - } - - void _onLoading() async { - if (mounted) setState(() {}); - _refreshController.loadComplete(); - } - - TextStyle _subStyle() { - return TextStyle( - fontSize: 24.sp, - color: Color(0xff999999), - ); - } - - Positioned _positionedTag(String tag) { - return Positioned( - top: 0, - right: 20.w, - child: Container( - padding: EdgeInsets.symmetric( - horizontal: 21.5.w, - vertical: 5.5.w), - decoration: BoxDecoration( - color: Color(0xfffff3cd), - border: Border.all(color: Color(0xffffc40c), width: 0.5), - borderRadius: BorderRadius.all(Radius.circular(22))), - child: Text( - tag, - style: TextStyle( - fontSize: 24.sp, - color: Color(0xff333333), - ), - ), - ), - ); - } - - Container _containerStaffCard(String name, String imagePath, String address, - String tenure, String post, String tag) { - return Container( - margin: EdgeInsets.only( - left: 32.w, - right: 32.w, - top: 20.w, - ), - padding: EdgeInsets.only( - left: 20.w, - top: 20.w, - bottom: 20.w, - ), - decoration: BoxDecoration( - color: Color(0xffffffff), - borderRadius: BorderRadius.all(Radius.circular(8))), - child: Stack( - children: [ - Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - CachedImageWrapper( - url: imagePath, - height: 150.w, - width: 150.w, - ), - SizedBox(width: 24.w), - Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - name, - style: TextStyle( - fontWeight: FontWeight.w600, - fontSize: 28.sp, - color: Color(0xff333333), - ), - ), - SizedBox(width: 10.w), - Text( - '住址:$address', - style: _subStyle(), - ), - SizedBox(width: 10.w), - Text( - '任职期限:$tenure', - style: _subStyle(), - ), - SizedBox(width: 10.w), - Text( - '从事岗位:$post', - style: _subStyle(), - ), - ], - ), - ], - ), - _positionedTag(tag), - ], - ), - ); - } - - @override - Widget build(BuildContext context) { - return SmartRefresher( - controller: _refreshController, - header: WaterDropHeader(), - footer: ClassicFooter(), - onRefresh: _onRefresh, - onLoading: _onLoading, - enablePullUp: false, - enablePullDown: false, - child: ListView.builder( - itemBuilder: (context, index) => _containerStaffCard( - _staffList[index]['name'], - _staffList[index]['imagePath'], - _staffList[index]['address'], - _staffList[index]['tenure'], - _staffList[index]['post'], - _staffList[index]['tag'], - ), - itemCount: _staffList.length, - ), - ); - } -} diff --git a/lib/pages/splash/splash_page.dart b/lib/pages/splash/splash_page.dart index 9bcad8e2..1c64e3f8 100644 --- a/lib/pages/splash/splash_page.dart +++ b/lib/pages/splash/splash_page.dart @@ -1,8 +1,10 @@ import 'package:akuCommunity/pages/tab_navigator.dart'; +import 'package:akuCommunity/provider/user_provider.dart'; import 'package:akuCommunity/utils/hive_store.dart'; import 'package:akuCommunity/utils/logger/logger_view.dart'; import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:provider/provider.dart'; import 'package:velocity_x/velocity_x.dart'; //TODO splashPage @@ -15,8 +17,11 @@ class SplashPage extends StatefulWidget { class _SplashPageState extends State { Future _initOp() async { + final userProvider = Provider.of(context, listen: false); await Future.delayed(Duration(seconds: 2)); - print(HiveStore.appBox.get('token')); + if (HiveStore.appBox.get('login') ?? false) { + await userProvider.setLogin(HiveStore.appBox.get('token')); + } } @override diff --git a/lib/provider/user_provider.dart b/lib/provider/user_provider.dart index 0339a090..84cc8463 100644 --- a/lib/provider/user_provider.dart +++ b/lib/provider/user_provider.dart @@ -21,6 +21,7 @@ class UserProvider extends ChangeNotifier { _isLogin = true; NetUtil().dio.options.headers.putIfAbsent('App-Admin-Token', () => token); HiveStore.appBox.put('token', token); + HiveStore.appBox.put('login', true); await updateProfile(); notifyListeners(); } @@ -32,6 +33,7 @@ class UserProvider extends ChangeNotifier { NetUtil().get(API.user.logout, showMessage: true); NetUtil().dio.options.headers.remove('App-Admin-Token'); HiveStore.appBox.delete('token'); + HiveStore.appBox.delete('login'); notifyListeners(); } diff --git a/lib/routers/page_routers.dart b/lib/routers/page_routers.dart index d190cd1f..09a9f87d 100644 --- a/lib/routers/page_routers.dart +++ b/lib/routers/page_routers.dart @@ -12,7 +12,6 @@ class Bundle { return _map[k]; } - putInt(String k, int v) => _map[k] = v; putString(String k, String v) => _setValue(k, v); @@ -28,8 +27,6 @@ class Bundle { bool getBool(String k) => _getValue(k) as bool; - List getList(String k) => _getValue(k) as List; - Map getMap(String k) => _getValue(k) as Map; @override diff --git a/lib/service/net_header.dart b/lib/service/net_header.dart index 4ada79cb..a424b7d0 100644 --- a/lib/service/net_header.dart +++ b/lib/service/net_header.dart @@ -1,6 +1,3 @@ -import 'package:akuCommunity/utils/sp_key.dart'; -import 'package:akuCommunity/utils/sp_util.dart'; - class NetHeader { /// 自定义Header static String appID = 'MOBILE-APP-ZNY'; @@ -9,8 +6,4 @@ class NetHeader { 'AppID': appID, 'AppSecret': appSecret, }; - static Future> getZnToken() async { - String znToken = await SpUtil.getString(SpKey.zntoken); - return {'Authorization': znToken ?? ''}; - } } diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index d89e8728..35863d59 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -13,13 +13,15 @@ class BeeScaffold extends StatefulWidget { final Color bgColor; final List actions; final Widget leading; + final Widget bottomNavi; BeeScaffold( {Key key, @required this.title, this.body, this.actions, this.leading, - this.bgColor}) + this.bgColor, + this.bottomNavi}) : super(key: key); @override @@ -41,6 +43,7 @@ class _BeeScaffoldState extends State { actions: widget.actions, ), body: widget.body, + bottomNavigationBar: widget.bottomNavi, ); } }