From 91799578907ee40f91ba7709963c6b38ebb62b70 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Wed, 1 Sep 2021 15:55:23 +0800 Subject: [PATCH] update list tile --- lib/list_tile/as_edit_tile.dart | 9 +++- lib/list_tile/as_list_tile.dart | 73 ++++++++++++++++++--------------- 2 files changed, 48 insertions(+), 34 deletions(-) diff --git a/lib/list_tile/as_edit_tile.dart b/lib/list_tile/as_edit_tile.dart index 19969a9..3330367 100644 --- a/lib/list_tile/as_edit_tile.dart +++ b/lib/list_tile/as_edit_tile.dart @@ -1,8 +1,8 @@ +import 'package:ansu_ui/extension/num_extension.dart'; +import 'package:ansu_ui/styles/as_colors.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:ansu_ui/styles/as_colors.dart'; -import 'package:ansu_ui/extension/num_extension.dart'; class ASEditTile extends StatelessWidget { final Widget? title; @@ -17,6 +17,8 @@ class ASEditTile extends StatelessWidget { final Widget? suffix; final bool? obscureText; final String? obscuringCharacter; + final bool enableEdit; + ASEditTile({ Key? key, this.title, @@ -31,7 +33,9 @@ class ASEditTile extends StatelessWidget { this.suffix, this.obscureText, this.obscuringCharacter, + this.enableEdit=true, }) : super(key: key); + @override Widget build(BuildContext context) { return ConstrainedBox( @@ -56,6 +60,7 @@ class ASEditTile extends StatelessWidget { Expanded( child: TextField( controller: controller, + enabled: enableEdit, onChanged: onChange, inputFormatters: inputFormatters, keyboardType: keyBoardType, diff --git a/lib/list_tile/as_list_tile.dart b/lib/list_tile/as_list_tile.dart index ae2c73f..1479a2e 100644 --- a/lib/list_tile/as_list_tile.dart +++ b/lib/list_tile/as_list_tile.dart @@ -17,6 +17,10 @@ class ASListTile extends StatelessWidget { ///对齐方式 final CrossAxisAlignment? crossAxisAlignment; + + ///是否显示 + final bool visible; + ASListTile({ Key? key, this.title, @@ -24,51 +28,56 @@ class ASListTile extends StatelessWidget { this.trail, this.height, this.crossAxisAlignment, + this.visible = true, }) : super(key: key); + ASListTile.option({ Key? key, this.title, this.text, this.trail, + this.visible = true, }) : height = 32.w, crossAxisAlignment = CrossAxisAlignment.center, super(key: key); @override Widget build(BuildContext context) { - return Container( - margin: height == null - ? EdgeInsets.symmetric(vertical: 8.w, horizontal: 10.w) - : EdgeInsets.symmetric(horizontal: 10.w), - height: height, - alignment: Alignment.centerLeft, - child: Row( - crossAxisAlignment: - crossAxisAlignment ?? CrossAxisAlignment.start, - children: [ - Container( - width: 85.w, - child: Text( - title!, - maxLines: 1, - overflow: TextOverflow.visible, - softWrap: false, - style: TextStyle(color: kTextColor, fontSize: 14.sp), + return Offstage( + offstage: !visible, + child: Container( + margin: height == null + ? EdgeInsets.symmetric(vertical: 8.w, horizontal: 10.w) + : EdgeInsets.symmetric(horizontal: 10.w), + height: height, + alignment: Alignment.centerLeft, + child: Row( + crossAxisAlignment: crossAxisAlignment ?? CrossAxisAlignment.start, + children: [ + Container( + width: 85.w, + child: Text( + title!, + maxLines: 1, + overflow: TextOverflow.visible, + softWrap: false, + style: TextStyle(color: kTextColor, fontSize: 14.sp), + ), + ), + Expanded( + child: text == null + ? Text('') + : text is String + ? Text( + text, + maxLines: 2, + style: TextStyle(color: kTextSubColor, fontSize: 14.sp), + ) + : text, ), - ), - Expanded( - child: text == null - ? Text('') - : text is String - ? Text( - text, - maxLines: 2, - style: TextStyle(color: kTextSubColor, fontSize: 14.sp), - ) - : text, - ), - trail ?? SizedBox() - ], + trail ?? SizedBox() + ], + ), ), ); }