# Conflicts:
#	example/lib/main.dart
null_safety
张萌 4 years ago
commit c9edb30402

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

@ -0,0 +1,39 @@
import 'package:ansu_ui/ansu_ui.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
class ExamplePicker extends StatefulWidget {
ExamplePicker({Key key}) : super(key: key);
@override
_ExamplePickerState createState() => _ExamplePickerState();
}
class _ExamplePickerState extends State<ExamplePicker> {
@override
Widget build(BuildContext context) {
return ASScaffold(
title: '选择器',
body: ListView(
children: [
ASButton(
title: '日期选择器 DatePicker',
onPressed: () async {
DateTime date = await asDatePicker(context);
Get.snackbar(date.toString(), 'MESSAGE');
},
),
ASButton(
title: '自定义选择器',
onPressed: () async {
Get.bottomSheet(ASPickerBox(
title: '自定义选择器',
child: Text('CHILD'),
));
},
),
],
),
);
}
}

@ -2,12 +2,14 @@ import 'package:ansu_ui/ansu_ui.dart';
import 'package:example/example_bottom_button.dart';
import 'package:example/example_tag.dart';
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:get/get.dart';
import 'example_numeric_button.dart';
import 'example_scaffold.dart';
import 'example_button.dart';
import 'example_tab_bar.dart';
import 'example_picker.dart';
void main() {
runApp(MyApp());
@ -19,6 +21,14 @@ class MyApp extends StatelessWidget {
return GetMaterialApp(
title: 'Flutter Demo',
home: _ScreenAdapter(),
localizationsDelegates: [
GlobalMaterialLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
],
supportedLocales: [
const Locale('zh'),
],
);
}
}
@ -47,6 +57,8 @@ class _MyHomePageState extends State<MyHomePage> {
body: ListView(
padding: EdgeInsets.all(16.w),
children: [
Image.asset('assets/logo.webp', height: 50),
SizedBox(height: 16.w),
ASButton.info(
title: '按钮 Button', onPressed: () => Get.to(ExampleButton())),
ASButton.info(
@ -56,6 +68,8 @@ class _MyHomePageState extends State<MyHomePage> {
ASButton.info(
title: '数量选择器NumericButton',
onPressed: () => Get.to(ExampleNumericButton())),
ASButton.info(
title: '选择器 Pickers', onPressed: () => Get.to(ExamplePicker())),
ASButton.info(
title: '底部按钮 BottomButton',
onPressed: () => Get.to(ExampleBottomButton()),

@ -69,6 +69,11 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_localizations:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_screenutil:
dependency: transitive
description:
@ -88,6 +93,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.17.1"
intl:
dependency: transitive
description:
name: intl
url: "https://pub.flutter-io.cn"
source: hosted
version: "0.16.1"
matcher:
dependency: transitive
description:

@ -3,7 +3,7 @@ description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
publish_to: "none" # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
@ -23,7 +23,8 @@ environment:
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
@ -41,7 +42,6 @@ dev_dependencies:
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
@ -51,13 +51,12 @@ flutter:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- assets/logo.webp
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a

@ -8,6 +8,8 @@ export 'scaffold/as_scaffold.dart';
export 'styles/as_colors.dart';
export 'bar/as_tabbar.dart';
export 'drawer/as_drawer.dart';
export 'pickers/as_date_picker.dart';
export 'pickers/as_picker_box.dart';
export 'utils/screen_adapter.dart';

@ -0,0 +1,24 @@
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASDivider extends StatelessWidget {
final Color color;
final double height;
final double indent;
final double endIndent;
ASDivider({Key key, this.indent, this.endIndent})
: color = const Color(0xFFE9E9E9),
height = 1.w,
super(key: key);
@override
Widget build(BuildContext context) {
return Divider(
color: color,
height: height,
thickness: height,
indent: indent,
endIndent: endIndent,
);
}
}

@ -0,0 +1,67 @@
import 'package:ansu_ui/pickers/as_picker_box.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
//
class _ASDatePickerWidget extends StatefulWidget {
_ASDatePickerWidget({Key key}) : super(key: key);
@override
_ASDatePickerWidgetState createState() => _ASDatePickerWidgetState();
}
class _ASDatePickerWidgetState extends State<_ASDatePickerWidget> {
DateTime _dateTime;
@override
void initState() {
super.initState();
_dateTime = DateTime.now();
}
@override
Widget build(BuildContext context) {
return ASPickerBox(
title: '日期',
onPressed: () {
Navigator.pop(context, _dateTime);
},
child: Padding(
padding: EdgeInsets.symmetric(horizontal: 18.w),
child: CupertinoDatePicker(
onDateTimeChanged: (dateTime) {
_dateTime = dateTime;
},
mode: CupertinoDatePickerMode.date,
),
),
);
}
}
///##
///
///``` dart
/// ASButton(
/// title: 'DatePicker',
/// onPressed: () async {
/// DateTime date = await asDatePicker(context);
/// Get.snackbar(date.toString(), 'MESSAGE');
/// },
/// )
///```
///
///`Future<DateTime>`
///
///使Navigator
///```dart
///Navigator.pop(context,dateTime)
///```
Future<DateTime> asDatePicker(BuildContext context) async {
return await showModalBottomSheet(
context: context,
builder: (context) {
return _ASDatePickerWidget();
},
);
}

@ -0,0 +1,80 @@
import 'package:ansu_ui/divider/as_divider.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASPickerBox extends StatelessWidget {
final VoidCallback onPressed;
final String confirmString;
final String title;
final Widget child;
const ASPickerBox(
{Key key,
this.onPressed,
this.confirmString = '完成',
this.title,
@required this.child})
: super(key: key);
_buildButton({
@required String title,
@required VoidCallback onPressed,
}) {
return TextButton(
style: ButtonStyle(
foregroundColor: MaterialStateProperty.all(kPrimaryColor),
overlayColor: MaterialStateProperty.all(kPrimaryColor.withOpacity(0.2)),
padding:
MaterialStateProperty.all(EdgeInsets.symmetric(horizontal: 20.w)),
textStyle: MaterialStateProperty.all(TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
)),
),
onPressed: onPressed,
child: Text(title),
);
}
@override
Widget build(BuildContext context) {
return Material(
color: kForegroundColor,
child: SizedBox(
height: 260.w,
child: Column(
mainAxisSize: MainAxisSize.min,
children: [
SizedBox(
height: 48.w,
child: Row(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
_buildButton(
title: '取消',
onPressed: () {
Navigator.pop(context);
}),
Expanded(
child: Center(
child: Text(
title ?? '',
style: TextStyle(
color: kTextColor,
fontSize: 16.sp,
),
),
),
),
_buildButton(title: confirmString, onPressed: onPressed),
],
),
),
ASDivider(),
Expanded(child: child),
],
),
),
);
}
}
Loading…
Cancel
Save