null_safety
小赖 3 years ago
parent dddb1fb09d
commit 0dc3065e95

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

@ -9,6 +9,7 @@ export 'buttons/as_bottom_button.dart';
export 'buttons/as_gradient_button.dart';
export 'buttons/as_radio_button.dart';
export 'buttons/as_material_button.dart';
export 'buttons/as_check_button.dart';
//scaffold
export 'scaffold/as_scaffold.dart';
@ -70,6 +71,8 @@ export 'extension/widget_extension.dart';
export 'extension/string_extension.dart';
export 'extension/text_style_extension.dart';
export 'extension/image_extension.dart';
export 'package:velocity_x/velocity_x.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;
ASTabBar(
{Key? key,
required this.items,
required this.controller,
this.isScrollable = false})
: tabItems = null,
final ValueChanged<int>? onTap;
ASTabBar({
Key? key,
required this.items,
required this.controller,
this.isScrollable = false,
this.onTap,
}) : tabItems = null,
super(key: key);
/// ## TabBar with tag
@ -41,12 +44,13 @@ class ASTabBar extends StatelessWidget implements PreferredSizeWidget {
/// )
///```
///
ASTabBar.tag(
{Key? key,
required this.tabItems,
required this.controller,
this.isScrollable = false})
: items = null,
ASTabBar.tag({
Key? key,
required this.tabItems,
required this.controller,
this.isScrollable = false,
this.onTap,
}) : items = null,
super(key: key);
bool get isTag => items?.isEmpty ?? true;
@ -57,6 +61,7 @@ class ASTabBar extends StatelessWidget implements PreferredSizeWidget {
child: TabBar(
isScrollable: isScrollable,
controller: controller,
onTap: onTap,
tabs: isTag
? tabItems!.map((e) {
return Tab(

@ -24,7 +24,11 @@ class ASBackButton extends StatelessWidget {
size: 24,
color: color,
),
onPressed: () => Navigator.pop(context),
onPressed: () {
if (Navigator.canPop(context)) {
Navigator.pop(context);
}
},
)
: 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,
color: kForegroundColor,
onPressed: () {
Navigator.pop(context);
onPressed!();
},
child: DefaultTextStyle(

@ -5,67 +5,62 @@ import 'package:ansu_ui/extension/num_extension.dart';
class ASEditTile extends StatelessWidget {
final Widget? title;
final FocusNode? node;
final String? hintText;
final Widget? prefix;
final TextEditingController? controller;
final Function(String text)? onChange;
final Function(String text)? onSubmitted;
ASEditTile({
Key? key,
this.title,
this.node,
this.hintText,
this.controller,
this.prefix,
this.onChange,
this.onSubmitted,
}) : super(key: key);
final FocusNode? _node = FocusNode();
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
if (node != null) {
node?.requestFocus();
} else {
_node?.requestFocus();
}
},
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: 46.w),
child: Row(
children: [
10.wb,
InkWell(
child: DefaultTextStyle(
style: TextStyle(
color: Colors.black.withOpacity(0.65),
fontSize: 14.sp,
),
child: title ?? Text(''),
return ConstrainedBox(
constraints: BoxConstraints(minHeight: 46.w),
child: Row(
children: [
10.wb,
InkWell(
child: DefaultTextStyle(
style: TextStyle(
color: Colors.black.withOpacity(0.65),
fontSize: 14.sp,
),
child: title ?? Text(''),
),
Expanded(
child: TextField(
focusNode: node ?? _node,
controller: controller,
textAlign: TextAlign.end,
style: TextStyle(
),
prefix ?? SizedBox(),
Expanded(
child: TextField(
controller: controller,
onChanged: onChange,
onSubmitted: onSubmitted,
textAlign: TextAlign.end,
style: TextStyle(
fontSize: 14.sp,
color: kTextColor,
fontWeight: FontWeight.bold,
),
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
hintText: hintText,
hintStyle: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
color: kTextColor,
fontWeight: FontWeight.bold,
),
decoration: InputDecoration(
border: InputBorder.none,
isDense: true,
contentPadding: EdgeInsets.zero,
hintText: hintText,
hintStyle: TextStyle(
color: kTextSubColor,
fontSize: 14.sp,
),
),
),
),
10.wb,
],
),
),
10.wb,
],
),
);
}

@ -9,15 +9,22 @@ class ASTheme {
}
static SystemUiOverlayStyle get defaultSystemStyle => SystemUiOverlayStyle(
systemNavigationBarColor: Colors.white,
systemNavigationBarColor: kBackgroundColor,
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light,
);
static SystemUiOverlayStyle get yellow =>
defaultSystemStyle.copyWith(systemNavigationBarColor: kPrimaryColor);
static ThemeData get lightTheme =>
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,
textButtonTheme: TextButtonThemeData(
style: ButtonStyle(

@ -1,9 +1,42 @@
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:get/get.dart';
import 'package:image_picker/image_picker.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 {
var pickedFile = await ImagePicker().getImage(

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

Loading…
Cancel
Save