From e2966ca68a515b5010ee7c75cbf182cf29941aca Mon Sep 17 00:00:00 2001 From: laiiihz Date: Fri, 22 Jan 2021 18:15:08 +0800 Subject: [PATCH] update advice page --- lib/ui/manager/advice/advice_page.dart | 14 +-- lib/ui/manager/advice/new_advice_page.dart | 117 +++++++++++++++++++++ lib/utils/sp_key.dart | 2 + lib/widget/bee_scaffold.dart | 21 +++- lib/widget/bottom_button.dart | 3 + lib/widget/buttons/bottom_button.dart | 36 +++++++ 6 files changed, 183 insertions(+), 10 deletions(-) create mode 100644 lib/ui/manager/advice/new_advice_page.dart create mode 100644 lib/widget/buttons/bottom_button.dart diff --git a/lib/ui/manager/advice/advice_page.dart b/lib/ui/manager/advice/advice_page.dart index aefb26a1..a2eae033 100644 --- a/lib/ui/manager/advice/advice_page.dart +++ b/lib/ui/manager/advice/advice_page.dart @@ -1,8 +1,10 @@ import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/manager/suggestion_or_complain_model.dart'; import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; +import 'package:akuCommunity/ui/manager/advice/new_advice_page.dart'; import 'package:akuCommunity/widget/bee_scaffold.dart'; import 'package:akuCommunity/utils/headers.dart'; +import 'package:akuCommunity/widget/buttons/bottom_button.dart'; import 'package:akuCommunity/widget/tab_bar/bee_tab_bar.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; @@ -12,13 +14,6 @@ enum AdviceType { COMPLAIN, } -enum _adviceInnerType { - SUGGESTION, - QUESTION, - COMPLAIN, - PRAISE, -} - class AdvicePage extends StatefulWidget { final AdviceType type; AdvicePage({Key key, @required this.type}) : super(key: key); @@ -64,6 +59,7 @@ class _AdvicePageState extends State with TickerProviderStateMixin { return index == 0 ? 4 : 3; break; } + return 0; } @override @@ -108,6 +104,10 @@ class _AdvicePageState extends State with TickerProviderStateMixin { ); }).toList(), ), + bottomNavi: BottomButton( + onPressed: NewAdvicePage(type: widget.type).to, + child: Text('新增'), + ), ); } } diff --git a/lib/ui/manager/advice/new_advice_page.dart b/lib/ui/manager/advice/new_advice_page.dart new file mode 100644 index 00000000..64c97cfb --- /dev/null +++ b/lib/ui/manager/advice/new_advice_page.dart @@ -0,0 +1,117 @@ +import 'package:akuCommunity/const/resource.dart'; +import 'package:akuCommunity/ui/manager/advice/advice_page.dart'; +import 'package:akuCommunity/widget/bee_scaffold.dart'; +import 'package:akuCommunity/utils/headers.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:velocity_x/velocity_x.dart'; + +class NewAdvicePage extends StatefulWidget { + final AdviceType type; + NewAdvicePage({Key key, @required this.type}) : super(key: key); + + @override + _NewAdvicePageState createState() => _NewAdvicePageState(); +} + +class _NewAdvicePageState extends State { + int _type = 0; + String get title { + switch (widget.type) { + case AdviceType.SUGGESTION: + return '建议咨询'; + break; + case AdviceType.COMPLAIN: + return '投诉表扬'; + break; + } + return ''; + } + + List get tabs { + switch (widget.type) { + case AdviceType.SUGGESTION: + return ['您的建议', '您的咨询']; + break; + case AdviceType.COMPLAIN: + return ['您的投诉', '您的表扬']; + break; + } + return []; + } + + _buildType(int index, String asset, String title) { + bool isSelected = _type == index; + return GestureDetector( + onTap: () { + _type = index; + setState(() {}); + }, + child: AnimatedContainer( + height: 72.w, + width: 176.w, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(36.w), + border: Border.all( + color: isSelected ? Color(0xFFFFC40C) : Color(0xFF979797), + width: 2.w, + ), + color: Color(0xFFFFF4D3).withOpacity(isSelected ? 1 : 0), + ), + duration: Duration(milliseconds: 300), + alignment: Alignment.center, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Image.asset(asset, width: 32.w, height: 32.w), + 12.wb, + title.text + .size(32.sp) + .color(isSelected ? Color(0xFF333333) : Color(0xFF999999)) + .make(), + ], + ), + ), + ); + } + + @override + Widget build(BuildContext context) { + return BeeScaffold.white( + title: title, + body: ListView( + padding: EdgeInsets.all(32.w), + children: [ + '业主/租客房屋'.text.size(28.sp).black.make(), + 32.hb, + [ + Image.asset( + R.ASSETS_IMAGES_HOUSE_ATTESTATION_PNG, + height: 60.w, + width: 60.w, + ), + 40.wb, + '宁波华茂悦峰\n1幢-1单元-702室'.text.size(32.sp).black.bold.make(), + ].row(), + Divider(height: 64.w), + '您要选择的类型是?'.text.size(28.sp).make(), + 32.hb, + [ + _buildType(0, R.ASSETS_ICONS_PROPOSAL_PNG, '建议'), + 80.wb, + _buildType(1, R.ASSETS_ICONS_CONSULT_PNG, '咨询'), + ].row(), + 44.hb, + '请输入内容'.text.size(28.sp).make(), + 24.hb, + TextField( + // controller: , + decoration: InputDecoration( + border: OutlineInputBorder(), + ), + ), + ], + ), + ); + } +} diff --git a/lib/utils/sp_key.dart b/lib/utils/sp_key.dart index 0c69fb91..f4bc5251 100644 --- a/lib/utils/sp_key.dart +++ b/lib/utils/sp_key.dart @@ -1,4 +1,6 @@ /// 所有Sp存储的键值对 +//TODO CLEAN BOTTOM CODES. +@Deprecated("sh*t sp_key need to be cleaned.") class SpKey { // 智能token static final String zntoken = "Authorization"; diff --git a/lib/widget/bee_scaffold.dart b/lib/widget/bee_scaffold.dart index 6ac9b5e3..fe0f71af 100644 --- a/lib/widget/bee_scaffold.dart +++ b/lib/widget/bee_scaffold.dart @@ -11,6 +11,8 @@ class BeeScaffold extends StatefulWidget { /// /// default Colors.white final Color bgColor; + + final Color bodyColor; final List actions; final Widget leading; final Widget bottomNavi; @@ -21,11 +23,24 @@ class BeeScaffold extends StatefulWidget { this.body, this.actions, this.leading, - this.bgColor, + this.bgColor = Colors.white, + this.bodyColor = const Color(0xFFF9F9F9), this.bottomNavi, this.appBarBottom}) : super(key: key); + BeeScaffold.white( + {Key key, + @required this.title, + this.body, + this.actions, + this.leading, + this.bgColor = Colors.white, + this.bottomNavi, + this.appBarBottom}) + : this.bodyColor = Colors.white, + super(key: key); + @override _BeeScaffoldState createState() => _BeeScaffoldState(); } @@ -34,9 +49,9 @@ class _BeeScaffoldState extends State { @override Widget build(BuildContext context) { return Scaffold( - backgroundColor: Color(0xFFF9F9F9), + backgroundColor: widget.bodyColor, appBar: AppBar( - backgroundColor: widget.bgColor ?? Colors.white, + backgroundColor: widget.bgColor, elevation: 0, title: widget.title.text.size(32.sp).color(Color(0xFF333333)).bold.make(), diff --git a/lib/widget/bottom_button.dart b/lib/widget/bottom_button.dart index f1672af7..d1652451 100644 --- a/lib/widget/bottom_button.dart +++ b/lib/widget/bottom_button.dart @@ -3,6 +3,9 @@ import 'package:flutter/cupertino.dart'; import 'package:akuCommunity/utils/headers.dart'; import 'package:akuCommunity/base/base_style.dart'; +//TODO CLEAN BOTTOM CODES. +//THIS IS SHIT BUTTON +@Deprecated("sh*t bottom_button need to be cleaned.") class BottomButton extends StatefulWidget { final String title; final Function fun; diff --git a/lib/widget/buttons/bottom_button.dart b/lib/widget/buttons/bottom_button.dart new file mode 100644 index 00000000..be102fc3 --- /dev/null +++ b/lib/widget/buttons/bottom_button.dart @@ -0,0 +1,36 @@ +import 'package:akuCommunity/base/base_style.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_screenutil/flutter_screenutil.dart'; + +class BottomButton extends StatelessWidget { + final VoidCallback onPressed; + final Widget child; + + const BottomButton({ + Key key, + @required this.onPressed, + @required this.child, + }) : super(key: key); + + @override + Widget build(BuildContext context) { + return Container( + color: kPrimaryColor, + padding: EdgeInsets.only(bottom: MediaQuery.of(context).padding.bottom), + child: MaterialButton( + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + child: DefaultTextStyle( + child: child, + style: TextStyle( + color: Colors.black, + fontWeight: FontWeight.bold, + fontSize: 32.sp, + ), + ), + onPressed: onPressed, + color: kPrimaryColor, + height: 98.w, + ), + ); + } +}