update scaffold

null_safety
小赖 4 years ago
parent 146dedbe3f
commit dddb1fb09d

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

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

@ -71,3 +71,5 @@ 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';

@ -21,19 +21,12 @@ class ASPickerBox extends StatelessWidget {
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,
)),
),
return SizedBox(
height: 48.w,
child: TextButton(
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_screenutil/flutter_screenutil.dart';
import 'package:ansu_ui/styles/as_colors.dart';
import 'package:ansu_ui/buttons/as_back_button.dart';
import 'package:flutter/services.dart';
///ASScaffold
///
@ -41,6 +42,8 @@ class ASScaffold extends StatelessWidget {
/// `AppBar` appBar
final Widget? appBar;
final SystemUiOverlayStyle? systemStyle;
///
final Color backgroundColor;
final Widget? floatingActionButton;
@ -56,31 +59,21 @@ class ASScaffold extends StatelessWidget {
this.backgroundColor = kBackgroundColor,
this.actions,
this.floatingActionButton,
this.systemStyle,
}) : super(key: key);
Widget get _title {
if (title is String) return Text(title);
return title ?? SizedBox();
return title;
}
Widget? get _appBar {
if (title == null && appBar == null && appBarBottom == null) return null;
return appBar ??
AppBar(
brightness: Brightness.light,
backgroundColor: kForegroundColor,
elevation: 0,
leading: leading ?? ASBackButton(),
actions: actions ?? [],
centerTitle: true,
title: DefaultTextStyle(
style: TextStyle(
color: kTextColor,
fontSize: 18.sp,
fontWeight: FontWeight.bold,
),
child: _title,
),
title: _title,
bottom: appBarBottom ??
PreferredSize(
child: SizedBox(),
@ -91,7 +84,9 @@ class ASScaffold extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
return AnnotatedRegion<SystemUiOverlayStyle>(
value: systemStyle ?? ASTheme.defaultSystemStyle,
child: Scaffold(
key: key,
endDrawer: endDrawer,
backgroundColor: backgroundColor,
@ -99,6 +94,7 @@ class ASScaffold extends StatelessWidget {
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:
dependency: "direct main"
description:
path: "."
ref: v2
resolved-ref: "73f03412c46b4662db6fb92fa18902d82c52e6b6"
url: "https://github.com/xuelongqy/flutter_easyrefresh"
source: git
version: "2.2.0"
name: flutter_easyrefresh
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.2.1"
flutter_plugin_android_lifecycle:
dependency: transitive
description:

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

Loading…
Cancel
Save