# Conflicts:
#	lib/ansu_ui.dart
null_safety
张萌 4 years ago
commit f1395e69ed

@ -24,7 +24,7 @@ List<ColorObject> colorObjects = [
codeName: 'kTextColor',
),
ColorObject(
color: Color.fromRGBO(0, 0, 0, 0.65),
color: Color(0xFF999999),
name: '次文本颜色',
codeName: 'kTextSubColor',
),

@ -84,12 +84,10 @@ class _ExampleButtonState extends State<ExampleButton> {
onPressed: () {},
),
),
ListTile(
trailing: Padding(
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,
ListTile(
title: Text(_pickedValue.toString()),
subtitle: Text('一般用法'),
trailing: ASNumericButton(
initValue: _pickedValue,
maxValue: 10,
onChange: (value) {},
onChange: (value) {
setState(() {
_pickedValue = value;
});
},
reachMax: (value) {
_showSnack(context, 'reach max');
},
reachMin: (value) {
_showSnack(context, 'reach min');
},
)
),
),
],
);
},

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

@ -1,5 +1,6 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExampleScaffold extends StatefulWidget {
ExampleScaffold({Key key}) : super(key: key);
@ -48,7 +49,18 @@ class _ExampleScaffoldState extends State<ExampleScaffold>
child: Text('open drawer'),
);
},
)
),
TextButton(
onPressed: () {
Get.dialog(
ASScaffold(
title: '框架 Scaffold',
),
useSafeArea: false,
);
},
child: Text('open drawer'),
),
],
),
);

@ -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(
return ListTile(
title: Text('${object.name} ${object.color.toString().substring(6, 16)}'),
subtitle: Text(object.codeName),
trailing: Card(
color: object.color,
backgroundColor:
object.color.value > 0xFFAAAAAA ? Colors.black : Colors.white,
child: SizedBox(height: 50.w, width: 50.w),
),
),
Card(
color: object.color,
child: SizedBox(height: 50.w, width: double.infinity),
),
SizedBox(height: 16.w),
],
);
}

@ -0,0 +1,31 @@
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: '搜索',
),
body: ListView(
children: [
ASSearchTextField.button(
hintText: '搜索',
onPressed: () {},
),
],
),
);
}
}

@ -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',
ASButton.info(
title: '列表内容项 ListTile',
onPressed: () => Get.to(ExampleListTile()),
)
),
ASButton.info(
title: '文本框 TextField',
onPressed: () => Get.to(ExampleTextFiled()),
),
],
),
);

@ -7,7 +7,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.2"
version: "0.0.4"
async:
dependency: transitive
description:

@ -7,6 +7,7 @@ export 'buttons/as_numeric_button.dart';
export 'buttons/as_bottom_button.dart';
export 'buttons/as_gradientbutton.dart';
export 'scaffold/as_scaffold.dart';
export 'styles/as_colors.dart';
export 'bar/as_tabbar.dart';
export 'drawer/as_drawer.dart';
@ -15,6 +16,8 @@ export 'pickers/as_picker_box.dart';
export 'dialog/as_dialog.dart';
export 'widget/as_listtile.dart';
export 'tag/as_tag.dart';
export 'divider/as_divider.dart';
export 'text_field/as_search_text_field.dart';
export 'utils/screen_adapter.dart';

@ -1,6 +1,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
///线
class ASDivider extends StatelessWidget {
final Color color;
final double height;
@ -22,3 +23,26 @@ class ASDivider extends StatelessWidget {
);
}
}
/// 线
class ASVDivider extends StatelessWidget {
final Color color;
final double height;
final double indent;
final double endIndent;
ASVDivider({Key key, this.indent, this.endIndent})
: color = const Color(0xFFE9E9E9),
height = 1.w,
super(key: key);
@override
Widget build(BuildContext context) {
return VerticalDivider(
color: color,
width: height,
thickness: height,
indent: indent,
endIndent: endIndent,
);
}
}

@ -7,9 +7,13 @@ import 'package:flutter_screenutil/flutter_screenutil.dart';
///
///made with Scaffold from `Material`
///
///`title`,`body`
///
///`leading`,`bottomNavigationBar`,`appBarBottom`
///
///`title`,`body`,`leading`,`bottomNavigationBar`,`appBarBottom`,`appBar`
///
///title , AppBar AppBarBottom `null`scaffoldAppBar
///
///AppBarBottomAppBarBottom
class ASScaffold extends StatefulWidget {
///`String``Text`
final dynamic title;
@ -30,14 +34,18 @@ class ASScaffold extends StatefulWidget {
///
///
final Widget endDrawer;
/// `AppBar` appBar
final Widget appBar;
ASScaffold({
Key key,
@required this.title,
this.title,
this.leading,
this.body,
this.bottomNavigationBar,
this.appBarBottom,
this.endDrawer,
this.appBar,
}) : super(key: key);
@override
@ -51,10 +59,18 @@ class _ASScaffoldState extends State<ASScaffold> {
endDrawer: widget.endDrawer,
backgroundColor: kBackgroundColor,
bottomNavigationBar: widget.bottomNavigationBar,
appBar: AppBar(
appBar: widget.title == null &&
widget.appBar == null &&
widget.appBarBottom == null
? null
: widget.appBar ??
AppBar(
brightness: Brightness.light,
backgroundColor: kForegroundColor,
elevation: 0,
toolbarHeight: widget.title == null && widget.appBar == null
? widget.appBarBottom.preferredSize.height + 2.0
: null,
leading: widget.leading ?? ASBackButton(),
centerTitle: true,
title: DefaultTextStyle(
@ -63,9 +79,15 @@ class _ASScaffoldState extends State<ASScaffold> {
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
child: widget.title is String ? Text(widget.title) : widget.title,
child: widget.title is String
? Text(widget.title)
: widget.title ?? SizedBox(),
),
bottom: widget.appBarBottom ??
PreferredSize(
child: SizedBox(),
preferredSize: Size.fromHeight(0),
),
bottom: widget.appBarBottom,
),
body: widget.body,
);

@ -7,7 +7,7 @@ const Color kDarkColor = Color(0xFF333333);
const Color kTextColor = kDarkColor;
///
const Color kTextSubColor = Color.fromRGBO(0, 0, 0, 0.65);
const Color kTextSubColor = Color(0xFF999999);
///
const Color kPrimaryColor = Color(0xFFF6B72D);

@ -0,0 +1,159 @@
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,
this.margin,
this.onPressed,
}) : button = false,
super(key: key);
///
ASSearchTextField.button({
Key key,
this.controller,
this.hintText,
this.onChanged,
this.focusNode,
this.onSubmitted,
this.margin,
this.onPressed,
}) : button = true,
super(key: key);
///
final bool button;
///
final TextEditingController controller;
///hint Text
final String hintText;
///
final ValueChanged<String> onChanged;
///
final ValueChanged<String> onSubmitted;
///
final FocusNode focusNode;
///margin
final EdgeInsets margin;
final VoidCallback onPressed;
@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),
width: 1.w,
),
);
_buildButton() {
return Padding(
padding: widget.margin ??
EdgeInsets.symmetric(
horizontal: 15.w,
vertical: 3.w,
),
child: MaterialButton(
padding: EdgeInsets.zero,
color: Color(0xFFF8F8F8),
elevation: 0,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(21.w),
side: BorderSide(
color: Color(0xFF979797),
width: 1.w,
),
),
child: Row(
children: [
Padding(
padding: EdgeInsets.only(left: 13.w, right: 8.w),
child: Icon(
Icons.search,
size: 16.w,
color: Colors.black,
),
),
Expanded(
child: Text(
widget.hintText ?? '',
style: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
),
),
),
],
),
onPressed: widget.onPressed,
),
);
}
@override
Widget build(BuildContext context) {
if (widget.button) return _buildButton();
return Container(
height: 42.w,
padding: widget.margin ??
EdgeInsets.symmetric(
horizontal: 15.w,
vertical: 3.w,
),
child: TextField(
controller: widget.controller,
onChanged: widget.onChanged,
onSubmitted: widget.onSubmitted,
onTap: widget.onPressed,
focusNode: widget.focusNode,
cursorColor: kPrimaryColor,
textInputAction: TextInputAction.search,
decoration: InputDecoration(
fillColor: Color(0xFFF8F8F8),
filled: true,
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.2
version: 0.0.4
author:
environment:

Loading…
Cancel
Save