123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- import 'package:ctjt_flutter/common/states.dart';
- import 'package:ctjt_flutter/common/styles.dart';
- import 'package:ctjt_flutter/common/utils.dart';
- import 'package:flutter/gestures.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_screenutil/flutter_screenutil.dart';
- import 'package:provider/provider.dart';
- /* ----------------------------------左侧抽屉--------------------------------- */
- class DrawerMenu extends StatelessWidget {
- String getUserShowName(BuildContext context) {
- String userName = Provider.of<UserStatus>(context, listen: false).userName;
- if (null == userName || userName.isEmpty) {
- return "";
- }
- userName = userName.trim();
- if (Utils.testCellNo(userName)) {
- userName = userName.substring(0, 3) + '****' + userName.substring(7);
- }
- return userName;
- }
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: 812.0.w,
- child: Drawer(
- child: Column(
- children: <Widget>[
- // 头部
- Container(
- width: double.infinity,
- height: 355.h,
- padding: EdgeInsets.fromLTRB(70.0.w,
- 102.0.h, 0, 0),
- child: Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: [
- Text("Test",
- style: TextStyle(
- fontSize: 72.0.w,
- fontWeight: FontWeight.normal,
- color: Styles.primaryColor)),
- Padding(
- padding: EdgeInsets.only(top: 30.h),
- ),
- Text(Provider.of<UserStatus>(context).userName.isEmpty ? '用户未登录' : '用户:' + getUserShowName(context),
- style: TextStyle(
- fontSize: 36.0.w,
- fontWeight: FontWeight.normal,
- color: Styles.primaryColor)),
- ],
- ),
- decoration: BoxDecoration(color: Colors.white, boxShadow: [
- BoxShadow(
- color: Colors.black12,
- offset: Offset(0.0, 0.0), //阴影xy轴偏移量
- blurRadius: ScreenUtil().radius(16), //阴影模糊程度
- spreadRadius: ScreenUtil().radius(2) //阴影扩散程度
- )
- ]),
- ),
- Padding(
- padding:
- EdgeInsets.fromLTRB(0, 35.0.h, 0, 0),
- ),
- ListTile(
- contentPadding: Styles.drawerTilePadding,
- title: Text("关于", style: Styles.drawerTileStyle),
- onTap: () {
- Utils.vibrate();
- Navigator.of(context).pop(); // 隐藏侧边栏
- Navigator.pushNamed(context, '/about');
- },
- ),
- Expanded( // 占满剩余空间
- child: Offstage(
- offstage: Provider.of<AppVersion>(context).appVersion.isEmpty,
- child: Container(
- alignment: Alignment.bottomLeft,
- padding: EdgeInsets.fromLTRB(
- 70.0.w,
- 0,
- 70.0.w,
- 170.0.h),
- child: Text('应用版本 ' + Provider.of<AppVersion>(context).appVersion,
- style: TextStyle(
- fontSize: 36.0.sp,
- fontWeight: FontWeight.normal,
- color: Colors.grey)),
- ),
- )
- ),
- ],
- ),
- ),
- );
- }
- }
|