张萌 4 years ago
commit da522a096b

@ -50,6 +50,11 @@ class _ExampleListTileState extends State<ExampleListTile> {
), ),
), ),
), ),
ASOptionTile.single(
item: ASEditTile(
title: Text('TEST'),
),
),
], ],
), ),
); );

@ -14,8 +14,11 @@ export 'drawer/as_drawer.dart';
export 'pickers/as_date_picker.dart'; export 'pickers/as_date_picker.dart';
export 'pickers/as_picker_box.dart'; export 'pickers/as_picker_box.dart';
export 'dialog/as_dialog.dart'; export 'dialog/as_dialog.dart';
export 'list_tile/as_list_tile.dart'; export 'list_tile/as_list_tile.dart';
export 'list_tile/as_option_tile.dart'; export 'list_tile/as_option_tile.dart';
export 'list_tile/as_edit_tile.dart';
export 'tag/as_tag.dart'; export 'tag/as_tag.dart';
export 'divider/as_divider.dart'; export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart'; export 'text_field/as_search_text_field.dart';

@ -0,0 +1,75 @@
import 'package:flutter/material.dart';
import 'package:ansu_ui/ansu_ui.dart';
class ASEditTile extends StatefulWidget {
final Widget title;
final FocusNode node;
final String hintText;
final TextEditingController controller;
ASEditTile({
Key key,
this.title,
this.node,
this.hintText,
@required this.controller,
}) : super(key: key);
@override
_ASEditTileState createState() => _ASEditTileState();
}
class _ASEditTileState extends State<ASEditTile> {
FocusNode _node;
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (widget.node != null) {
widget.node?.requestFocus();
} else {
_node?.requestFocus();
}
},
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 46.w),
child: Row(
children: [
10.wb,
InkWell(
child: DefaultTextStyle(
style: TextStyle(
color: Colors.black.withOpacity(0.65),
fontSize: 14.sp,
),
child: widget.title ?? Text(''),
),
),
Expanded(
child: TextField(
focusNode: widget.node ?? _node,
controller: widget.controller,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: kTextColor,
fontWeight: FontWeight.bold,
),
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
hintText: widget.hintText,
hintStyle: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
),
),
),
),
10.wb,
],
),
),
);
}
}

@ -7,10 +7,16 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
///Tile ///Tile
class ASOptionTile extends StatelessWidget { class ASOptionTile extends StatelessWidget {
///使 ASOptionTileItem ///使 ASOptionTileItem
final List<Widget> items; final List<Widget> items;
const ASOptionTile({Key key, @required this.items}) : super(key: key);
///Widget
final Widget item;
ASOptionTile({Key key, this.items, this.item}) : super(key: key);
ASOptionTile.single({Key key, @required this.item})
: items = [],
super(key: key);
int get length => items.length; int get length => items.length;
@ -21,13 +27,14 @@ class ASOptionTile extends StatelessWidget {
shape: RoundedRectangleBorder( shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(5.w), borderRadius: BorderRadius.circular(5.w),
), ),
child: Column( child: item ??
Column(
children: List.generate(length * 2 - 1, (index) { children: List.generate(length * 2 - 1, (index) {
final displayIndex = index ~/ 2; final displayIndex = index ~/ 2;
if (index.isEven) if (index.isEven)
return items[displayIndex]; return items[displayIndex];
else else
return ASDivider(); return ASDivider(indent: 14.w, endIndent: 14.w);
}), }),
), ),
); );

Loading…
Cancel
Save