add searchTextField

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

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

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

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

@ -11,24 +11,13 @@ class ExampleStyleColor extends StatefulWidget {
class _ExampleStyleColorState extends State<ExampleStyleColor> {
_buildCard(ColorObject object) {
return Column(
children: [
Text(object.name),
Text(object.codeName),
Text(
object.color.toString(),
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),
],
return ListTile(
title: Text('${object.name} ${object.color.toString().substring(6, 16)}'),
subtitle: Text(object.codeName),
trailing: Card(
color: object.color,
child: SizedBox(height: 50.w, width: 50.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_listtile.dart';
import 'package:example/example_tag.dart';
import 'package:example/example_text_field.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
@ -108,9 +109,14 @@ class _MyHomePageState extends State<MyHomePage> {
title: '对话框 Dialog',
onPressed: () => Get.to(ExampleDialog()),
),
ASButton.info(title:'列表内容项 ListTile',
onPressed: () => Get.to(ExampleListTile()),
)
ASButton.info(
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 'divider/as_divider.dart';
export 'tag/as_tag.dart';
export 'text_field/as_search_text_field.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
description: A new Flutter package.
version: 0.0.3
version: 0.0.4
author:
environment:

Loading…
Cancel
Save