update scaffold

null_safety
小赖 4 years ago
parent 146dedbe3f
commit dddb1fb09d

@ -22,6 +22,7 @@ class MyApp extends StatelessWidget {
title: 'Flutter Demo', title: 'Flutter Demo',
home: MyHomePage(), home: MyHomePage(),
builder: BotToastInit(), builder: BotToastInit(),
theme: ASTheme.lightTheme,
navigatorObservers: [BotToastNavigatorObserver()], navigatorObservers: [BotToastNavigatorObserver()],
localizationsDelegates: [ localizationsDelegates: [
GlobalMaterialLocalizations.delegate, GlobalMaterialLocalizations.delegate,
@ -49,9 +50,7 @@ class _MyHomePageState extends State<MyHomePage> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
super.initState(); super.initState();
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light.copyWith( ASTheme.init();
statusBarColor: Colors.transparent,
));
_tabController = TabController(length: 3, vsync: this); _tabController = TabController(length: 3, vsync: this);
} }

@ -116,12 +116,10 @@ packages:
flutter_easyrefresh: flutter_easyrefresh:
dependency: transitive dependency: transitive
description: description:
path: "." name: flutter_easyrefresh
ref: v2 url: "https://pub.flutter-io.cn"
resolved-ref: "73f03412c46b4662db6fb92fa18902d82c52e6b6" source: hosted
url: "https://github.com/xuelongqy/flutter_easyrefresh" version: "2.2.1"
source: git
version: "2.2.0"
flutter_localizations: flutter_localizations:
dependency: "direct main" dependency: "direct main"
description: flutter description: flutter

@ -71,3 +71,5 @@ 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 'package:velocity_x/velocity_x.dart';
export 'theme/as_theme.dart';

@ -21,19 +21,12 @@ class ASPickerBox extends StatelessWidget {
required String title, required String title,
required VoidCallback? onPressed, required VoidCallback? onPressed,
}) { }) {
return TextButton( return SizedBox(
style: ButtonStyle( height: 48.w,
foregroundColor: MaterialStateProperty.all(kPrimaryColor), child: TextButton(
overlayColor: MaterialStateProperty.all(kPrimaryColor.withOpacity(0.2)), onPressed: onPressed,
padding: child: Text(title),
MaterialStateProperty.all(EdgeInsets.symmetric(horizontal: 20.w)),
textStyle: MaterialStateProperty.all(TextStyle(
fontSize: 16.sp,
fontWeight: FontWeight.w500,
)),
), ),
onPressed: onPressed,
child: Text(title),
); );
} }

@ -1,7 +1,8 @@
import 'package:ansu_ui/theme/as_theme.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/styles/as_colors.dart'; import 'package:ansu_ui/styles/as_colors.dart';
import 'package:ansu_ui/buttons/as_back_button.dart'; import 'package:ansu_ui/buttons/as_back_button.dart';
import 'package:flutter/services.dart';
///ASScaffold ///ASScaffold
/// ///
@ -41,6 +42,8 @@ class ASScaffold extends StatelessWidget {
/// `AppBar` appBar /// `AppBar` appBar
final Widget? appBar; final Widget? appBar;
final SystemUiOverlayStyle? systemStyle;
/// ///
final Color backgroundColor; final Color backgroundColor;
final Widget? floatingActionButton; final Widget? floatingActionButton;
@ -56,31 +59,21 @@ class ASScaffold extends StatelessWidget {
this.backgroundColor = kBackgroundColor, this.backgroundColor = kBackgroundColor,
this.actions, this.actions,
this.floatingActionButton, this.floatingActionButton,
this.systemStyle,
}) : super(key: key); }) : super(key: key);
Widget get _title { Widget get _title {
if (title is String) return Text(title); if (title is String) return Text(title);
return title ?? SizedBox(); return title;
} }
Widget? get _appBar { Widget? get _appBar {
if (title == null && appBar == null && appBarBottom == null) return null; if (title == null && appBar == null && appBarBottom == null) return null;
return appBar ?? return appBar ??
AppBar( AppBar(
brightness: Brightness.light,
backgroundColor: kForegroundColor,
elevation: 0,
leading: leading ?? ASBackButton(), leading: leading ?? ASBackButton(),
actions: actions ?? [], actions: actions ?? [],
centerTitle: true, title: _title,
title: DefaultTextStyle(
style: TextStyle(
color: kTextColor,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
child: _title,
),
bottom: appBarBottom ?? bottom: appBarBottom ??
PreferredSize( PreferredSize(
child: SizedBox(), child: SizedBox(),
@ -91,14 +84,17 @@ class ASScaffold extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return AnnotatedRegion<SystemUiOverlayStyle>(
key: key, value: systemStyle ?? ASTheme.defaultSystemStyle,
endDrawer: endDrawer, child: Scaffold(
backgroundColor: backgroundColor, key: key,
bottomNavigationBar: bottomNavigationBar, endDrawer: endDrawer,
floatingActionButton: floatingActionButton, backgroundColor: backgroundColor,
appBar: _appBar as PreferredSizeWidget?, bottomNavigationBar: bottomNavigationBar,
body: body, floatingActionButton: floatingActionButton,
appBar: _appBar as PreferredSizeWidget?,
body: body,
),
); );
} }
} }

@ -0,0 +1,50 @@
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class ASTheme {
static init() {
SystemChrome.setSystemUIOverlayStyle(defaultSystemStyle);
}
static SystemUiOverlayStyle get defaultSystemStyle => SystemUiOverlayStyle(
systemNavigationBarColor: Colors.white,
statusBarColor: Colors.transparent,
statusBarIconBrightness: Brightness.light,
statusBarBrightness: Brightness.light,
);
static ThemeData get lightTheme =>
ThemeData(primarySwatch: Colors.yellow).copyWith(
textTheme: TextTheme().apply(displayColor: Color(0xFF333333)),
primaryColor: kPrimaryColor,
textButtonTheme: TextButtonThemeData(
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,
)),
),
),
appBarTheme: AppBarTheme(
brightness: Brightness.light,
backgroundColor: kForegroundColor,
elevation: 0,
centerTitle: true,
textTheme: TextTheme(
headline6: TextStyle(
color: kTextColor,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
),
),
);
}

@ -95,12 +95,10 @@ packages:
flutter_easyrefresh: flutter_easyrefresh:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." name: flutter_easyrefresh
ref: v2 url: "https://pub.flutter-io.cn"
resolved-ref: "73f03412c46b4662db6fb92fa18902d82c52e6b6" source: hosted
url: "https://github.com/xuelongqy/flutter_easyrefresh" version: "2.2.1"
source: git
version: "2.2.0"
flutter_plugin_android_lifecycle: flutter_plugin_android_lifecycle:
dependency: transitive dependency: transitive
description: description:

@ -11,10 +11,7 @@ dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
flutter_screenutil: ^5.0.0 flutter_screenutil: ^5.0.0
flutter_easyrefresh: flutter_easyrefresh: ^2.2.1
git:
url: https://github.com/xuelongqy/flutter_easyrefresh
ref: v2
lpinyin: ^2.0.1 lpinyin: ^2.0.1
image_picker: ^0.7.2 image_picker: ^0.7.2
bot_toast: ^4.0.0+1 bot_toast: ^4.0.0+1

Loading…
Cancel
Save