null_safety
小赖 4 years ago
parent dddb1fb09d
commit 0dc3065e95

@ -57,6 +57,7 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
print(Theme.of(context).textTheme.headline1.fontFamily);
return ASScaffold( return ASScaffold(
leading: navigator.canPop() leading: navigator.canPop()
? IconButton( ? IconButton(

@ -90,6 +90,16 @@ class _ExamplePickerState extends State<ExamplePicker> {
}, },
), ),
), ),
ListTile(
title: Text('图片选择器'),
subtitle: Text('ImagePicker'),
trailing: ASButton(
title: '图片选择器',
onPressed: () async {
File file = await pickImageFile();
},
),
),
// END // END
], ],
), ),

@ -9,6 +9,7 @@ export 'buttons/as_bottom_button.dart';
export 'buttons/as_gradient_button.dart'; export 'buttons/as_gradient_button.dart';
export 'buttons/as_radio_button.dart'; export 'buttons/as_radio_button.dart';
export 'buttons/as_material_button.dart'; export 'buttons/as_material_button.dart';
export 'buttons/as_check_button.dart';
//scaffold //scaffold
export 'scaffold/as_scaffold.dart'; export 'scaffold/as_scaffold.dart';
@ -70,6 +71,8 @@ export 'extension/widget_extension.dart';
export 'extension/string_extension.dart'; export 'extension/string_extension.dart';
export 'extension/text_style_extension.dart'; export 'extension/text_style_extension.dart';
export 'extension/image_extension.dart'; export 'extension/image_extension.dart';
export 'package:velocity_x/velocity_x.dart';
export 'theme/as_theme.dart'; export 'theme/as_theme.dart';
//third party
export 'package:velocity_x/velocity_x.dart';

@ -21,12 +21,15 @@ class ASTabBar extends StatelessWidget implements PreferredSizeWidget {
/// ///
final bool isScrollable; final bool isScrollable;
ASTabBar(
{Key? key, final ValueChanged<int>? onTap;
ASTabBar({
Key? key,
required this.items, required this.items,
required this.controller, required this.controller,
this.isScrollable = false}) this.isScrollable = false,
: tabItems = null, this.onTap,
}) : tabItems = null,
super(key: key); super(key: key);
/// ## TabBar with tag /// ## TabBar with tag
@ -41,12 +44,13 @@ class ASTabBar extends StatelessWidget implements PreferredSizeWidget {
/// ) /// )
///``` ///```
/// ///
ASTabBar.tag( ASTabBar.tag({
{Key? key, Key? key,
required this.tabItems, required this.tabItems,
required this.controller, required this.controller,
this.isScrollable = false}) this.isScrollable = false,
: items = null, this.onTap,
}) : items = null,
super(key: key); super(key: key);
bool get isTag => items?.isEmpty ?? true; bool get isTag => items?.isEmpty ?? true;
@ -57,6 +61,7 @@ class ASTabBar extends StatelessWidget implements PreferredSizeWidget {
child: TabBar( child: TabBar(
isScrollable: isScrollable, isScrollable: isScrollable,
controller: controller, controller: controller,
onTap: onTap,
tabs: isTag tabs: isTag
? tabItems!.map((e) { ? tabItems!.map((e) {
return Tab( return Tab(

@ -24,7 +24,11 @@ class ASBackButton extends StatelessWidget {
size: 24, size: 24,
color: color, color: color,
), ),
onPressed: () => Navigator.pop(context), onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
) )
: SizedBox(); : SizedBox();
} }

@ -0,0 +1,36 @@
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter/material.dart';
class ASCheckButton<T> extends StatelessWidget {
final T object;
final bool checked;
final VoidCallback onTap;
final String title;
const ASCheckButton({
Key? key,
required this.object,
required this.onTap,
this.checked = false,
required this.title,
}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialButton(
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
height: 31.w,
onPressed: onTap,
shape: StadiumBorder(),
color: checked ? kPrimaryColor : Color(0xFFF2F2F2),
elevation: 0,
child: Text(
title,
style: TextStyle(
color: checked ? kLightTextColor : kTextColor,
),
),
);
}
}

@ -17,7 +17,6 @@ class ASBottomDialogItem extends StatelessWidget {
height: 48.w, height: 48.w,
color: kForegroundColor, color: kForegroundColor,
onPressed: () { onPressed: () {
Navigator.pop(context);
onPressed!(); onPressed!();
}, },
child: DefaultTextStyle( child: DefaultTextStyle(

@ -5,29 +5,23 @@ import 'package:ansu_ui/extension/num_extension.dart';
class ASEditTile extends StatelessWidget { class ASEditTile extends StatelessWidget {
final Widget? title; final Widget? title;
final FocusNode? node;
final String? hintText; final String? hintText;
final Widget? prefix;
final TextEditingController? controller; final TextEditingController? controller;
final Function(String text)? onChange;
final Function(String text)? onSubmitted;
ASEditTile({ ASEditTile({
Key? key, Key? key,
this.title, this.title,
this.node,
this.hintText, this.hintText,
this.controller, this.controller,
this.prefix,
this.onChange,
this.onSubmitted,
}) : super(key: key); }) : super(key: key);
final FocusNode? _node = FocusNode();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return GestureDetector( return ConstrainedBox(
onTap: () {
if (node != null) {
node?.requestFocus();
} else {
_node?.requestFocus();
}
},
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 46.w), constraints: BoxConstraints(minHeight: 46.w),
child: Row( child: Row(
children: [ children: [
@ -41,10 +35,12 @@ class ASEditTile extends StatelessWidget {
child: title ?? Text(''), child: title ?? Text(''),
), ),
), ),
prefix ?? SizedBox(),
Expanded( Expanded(
child: TextField( child: TextField(
focusNode: node ?? _node,
controller: controller, controller: controller,
onChanged: onChange,
onSubmitted: onSubmitted,
textAlign: TextAlign.end, textAlign: TextAlign.end,
style: TextStyle( style: TextStyle(
fontSize: 14.sp, fontSize: 14.sp,
@ -66,7 +62,6 @@ class ASEditTile extends StatelessWidget {
10.wb, 10.wb,
], ],
), ),
),
); );
} }
} }

@ -9,15 +9,22 @@ class ASTheme {
} }
static SystemUiOverlayStyle get defaultSystemStyle => SystemUiOverlayStyle( static SystemUiOverlayStyle get defaultSystemStyle => SystemUiOverlayStyle(
systemNavigationBarColor: Colors.white, systemNavigationBarColor: kBackgroundColor,
statusBarColor: Colors.transparent, statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light, statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light, statusBarBrightness: Brightness.light,
); );
static SystemUiOverlayStyle get yellow =>
defaultSystemStyle.copyWith(systemNavigationBarColor: kPrimaryColor);
static ThemeData get lightTheme => static ThemeData get lightTheme =>
ThemeData(primarySwatch: Colors.yellow).copyWith( ThemeData(primarySwatch: Colors.yellow).copyWith(
textTheme: TextTheme().apply(displayColor: Color(0xFF333333)), textTheme: ThemeData.light().textTheme.apply(
displayColor: Color(0xFF333333),
bodyColor: Color(0xFF333333),
),
inputDecorationTheme: InputDecorationTheme(),
primaryColor: kPrimaryColor, primaryColor: kPrimaryColor,
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(

@ -1,9 +1,42 @@
import 'dart:io'; import 'dart:io';
import 'package:ansu_ui/dialog/as_bottom_dialog.dart';
import 'package:ansu_ui/dialog/as_bottom_dialog_item.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:image_picker/image_picker.dart'; import 'package:image_picker/image_picker.dart';
import 'package:ansu_ui/utils/camera_view.dart'; import 'package:ansu_ui/utils/camera_view.dart';
Future<File?> pickImageFile(
{double maxHeight = 3000, double maxWidth = 3000}) async {
File? file = await Get.bottomSheet(ASBottomDialog(
items: [
ASBottomDialogItem(
title: Text('相机'),
onPressed: () async {
Get.back(result: await camFile());
},
),
ASBottomDialogItem(
title: Text('相册'),
onPressed: () async {
var pickedFile = await ImagePicker().getImage(
source: ImageSource.gallery,
maxHeight: maxHeight,
maxWidth: maxWidth,
);
if (pickedFile != null) {
Get.back(result: File(pickedFile.path));
} else {
Get.back();
}
},
),
],
));
return file;
}
/// ///
Future<File?> camFile({double maxHeight = 3000, double maxWidth = 3000}) async { Future<File?> camFile({double maxHeight = 3000, double maxWidth = 3000}) async {
var pickedFile = await ImagePicker().getImage( var pickedFile = await ImagePicker().getImage(

@ -4,7 +4,7 @@ version: 0.0.4
author: author:
environment: environment:
sdk: '>=2.12.0 <3.0.0' sdk: ">=2.12.0 <3.0.0"
flutter: ">=1.17.0" flutter: ">=1.17.0"
dependencies: dependencies:
@ -25,4 +25,3 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
flutter:

Loading…
Cancel
Save