add searchTextField

null_safety
小赖 4 years ago
parent 1895a9a8c8
commit 0fc94b71ae

@ -50,7 +50,7 @@ class _ExampleButtonState extends State<ExampleButton> {
title: '立即下单', title: '立即下单',
onPressed: () {}, onPressed: () {},
)), )),
ListTile( ListTile(
title: Text('order'), title: Text('order'),
subtitle: Text('null function'), subtitle: Text('null function'),
trailing: ASButton.order( trailing: ASButton.order(
@ -84,11 +84,9 @@ class _ExampleButtonState extends State<ExampleButton> {
onPressed: () {}, onPressed: () {},
), ),
), ),
ListTile( Padding(
trailing: Padding( padding: EdgeInsets.symmetric(horizontal: 100.w),
padding: EdgeInsets.symmetric(horizontal: 100.w), child: ASLongButton.solid(title: 'adaptable', onPressed: () {}),
child: ASLongButton.solid(title: 'adaptable', onPressed: () {}),
),
), ),
SizedBox( SizedBox(
height: 12.w, height: 12.w,

@ -15,6 +15,8 @@ class _ExampleNumericButtonState extends State<ExampleNumericButton> {
); );
} }
int _pickedValue = 0;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return ASScaffold( return ASScaffold(
@ -23,17 +25,25 @@ class _ExampleNumericButtonState extends State<ExampleNumericButton> {
builder: (context) { builder: (context) {
return ListView( return ListView(
children: [ children: [
ASNumericButton( ListTile(
initValue: 0, title: Text(_pickedValue.toString()),
maxValue: 10, subtitle: Text('一般用法'),
onChange: (value) {}, trailing: ASNumericButton(
reachMax: (value) { initValue: _pickedValue,
_showSnack(context, 'reach max'); maxValue: 10,
}, onChange: (value) {
reachMin: (value) { setState(() {
_showSnack(context, 'reach min'); _pickedValue = value;
}, });
) },
reachMax: (value) {
_showSnack(context, 'reach max');
},
reachMin: (value) {
_showSnack(context, 'reach min');
},
),
),
], ],
); );
}, },

@ -16,21 +16,29 @@ class _ExamplePickerState extends State<ExamplePicker> {
title: '选择器', title: '选择器',
body: ListView( body: ListView(
children: [ children: [
ASButton( ListTile(
title: '日期选择器 DatePicker', title: Text('日期选择器'),
onPressed: () async { subtitle: Text('DatePicker'),
DateTime date = await asDatePicker(context); trailing: ASButton(
Get.snackbar(date.toString(), 'MESSAGE'); title: '日期选择器',
}, onPressed: () async {
DateTime date = await asDatePicker(context);
Get.snackbar(date.toString(), 'MESSAGE');
},
),
), ),
ASButton( ListTile(
title: '自定义选择器', title: Text('自定义选择器'),
onPressed: () async { subtitle: Text('CustomPicker'),
Get.bottomSheet(ASPickerBox( trailing: ASButton(
title: '自定义选择器', title: '自定义选择器',
child: Text('CHILD'), onPressed: () async {
)); Get.bottomSheet(ASPickerBox(
}, title: '自定义选择器',
child: Text('CHILD'),
));
},
),
), ),
], ],
), ),

@ -11,24 +11,13 @@ class ExampleStyleColor extends StatefulWidget {
class _ExampleStyleColorState extends State<ExampleStyleColor> { class _ExampleStyleColorState extends State<ExampleStyleColor> {
_buildCard(ColorObject object) { _buildCard(ColorObject object) {
return Column( return ListTile(
children: [ title: Text('${object.name} ${object.color.toString().substring(6, 16)}'),
Text(object.name), subtitle: Text(object.codeName),
Text(object.codeName), trailing: Card(
Text( color: object.color,
object.color.toString(), child: SizedBox(height: 50.w, width: 50.w),
style: TextStyle( ),
color: object.color,
backgroundColor:
object.color.value > 0xFFAAAAAA ? Colors.black : Colors.white,
),
),
Card(
color: object.color,
child: SizedBox(height: 50.w, width: double.infinity),
),
SizedBox(height: 16.w),
],
); );
} }

@ -0,0 +1,23 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
class ExampleTextFiled extends StatefulWidget {
ExampleTextFiled({Key key}) : super(key: key);
@override
_ExampleTextFiledState createState() => _ExampleTextFiledState();
}
class _ExampleTextFiledState extends State<ExampleTextFiled> {
TextEditingController _controller;
@override
Widget build(BuildContext context) {
return ASScaffold(
title: '文本框 TextFiled',
appBarBottom: ASSearchTextField(
controller: _controller,
hintText: '搜索',
),
);
}
}

@ -4,6 +4,7 @@ import 'package:example/example_dialog.dart';
import 'package:example/example_drawer.dart'; import 'package:example/example_drawer.dart';
import 'package:example/example_listtile.dart'; import 'package:example/example_listtile.dart';
import 'package:example/example_tag.dart'; import 'package:example/example_tag.dart';
import 'package:example/example_text_field.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart'; import 'package:flutter_localizations/flutter_localizations.dart';
@ -108,9 +109,14 @@ class _MyHomePageState extends State<MyHomePage> {
title: '对话框 Dialog', title: '对话框 Dialog',
onPressed: () => Get.to(ExampleDialog()), onPressed: () => Get.to(ExampleDialog()),
), ),
ASButton.info(title:'列表内容项 ListTile', ASButton.info(
onPressed: () => Get.to(ExampleListTile()), title: '列表内容项 ListTile',
) onPressed: () => Get.to(ExampleListTile()),
),
ASButton.info(
title: '文本框 TextField',
onPressed: () => Get.to(ExampleTextFiled()),
),
], ],
), ),
); );

@ -17,6 +17,7 @@ export 'pickers/as_picker_box.dart';
export 'dialog/as_dialog.dart'; export 'dialog/as_dialog.dart';
export 'divider/as_divider.dart'; export 'divider/as_divider.dart';
export 'tag/as_tag.dart'; export 'tag/as_tag.dart';
export 'text_field/as_search_text_field.dart';
export 'utils/screen_adapter.dart'; export 'utils/screen_adapter.dart';

@ -0,0 +1,85 @@
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///TextFiled
class ASSearchTextField extends StatefulWidget implements PreferredSizeWidget {
ASSearchTextField({
Key key,
this.controller,
this.hintText,
this.onChanged,
this.focusNode,
this.onSubmitted,
}) : super(key: key);
///
final TextEditingController controller;
///hint Text
final String hintText;
///
final ValueChanged<String> onChanged;
///
final ValueChanged<String> onSubmitted;
///
final FocusNode focusNode;
@override
_ASSearchTextFieldState createState() => _ASSearchTextFieldState();
@override
Size get preferredSize => Size.fromHeight(42.w);
}
class _ASSearchTextFieldState extends State<ASSearchTextField> {
get _border => OutlineInputBorder(
borderRadius: BorderRadius.circular(21.w),
borderSide: BorderSide(
color: Color(0xFF979797),
),
);
@override
Widget build(BuildContext context) {
return Container(
height: 42.w,
padding: EdgeInsets.symmetric(
horizontal: 15.w,
vertical: 3.w,
),
child: TextField(
controller: widget.controller,
onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
focusNode: widget.focusNode,
cursorColor: kPrimaryColor,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
hintText: widget.hintText,
hintStyle: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
),
border: _border,
enabledBorder: _border,
focusedBorder: _border,
focusedErrorBorder: _border,
prefixIcon: Padding(
padding: EdgeInsets.only(left: 13.w, right: 8.w),
child: Icon(
Icons.search,
size: 16.w,
color: Colors.black,
),
),
prefixIconConstraints: BoxConstraints(minWidth: 0, minHeight: 0),
contentPadding: EdgeInsets.zero,
),
),
);
}
}

@ -1,6 +1,6 @@
name: ansu_ui name: ansu_ui
description: A new Flutter package. description: A new Flutter package.
version: 0.0.3 version: 0.0.4
author: author:
environment: environment:

Loading…
Cancel
Save