parent
5279ced9c2
commit
fb60f29c88
@ -1,193 +0,0 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class AppTheme {
|
||||
static ThemeData get theme {
|
||||
return ThemeData(primarySwatch: Colors.blue).copyWith(
|
||||
primaryColor: const Color(0xFF027AFF),
|
||||
extensions: <ThemeExtension<dynamic>>[
|
||||
MyAppStyle(
|
||||
mainColor: Colors.blue,
|
||||
bodyText3: TextStyle(
|
||||
fontSize: 30.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
)
|
||||
],
|
||||
textTheme: ThemeData.light().textTheme.copyWith(
|
||||
headline3: TextStyle(
|
||||
fontSize: 40.sp,
|
||||
color: const Color(0xFF333333),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
headline4: TextStyle(
|
||||
fontSize: 36.sp,
|
||||
color: const Color(0xFF111111),
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
subtitle1: TextStyle(
|
||||
fontSize: 32.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
subtitle2: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
bodyText1: TextStyle(
|
||||
fontSize: 24.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
bodyText2: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
color: const Color(0xFF333333),
|
||||
),
|
||||
),
|
||||
floatingActionButtonTheme: const FloatingActionButtonThemeData().copyWith(
|
||||
backgroundColor: const Color(0xFFFFD000),
|
||||
),
|
||||
appBarTheme: AppBarTheme(
|
||||
elevation: 0,
|
||||
centerTitle: true,
|
||||
iconTheme: const IconThemeData(
|
||||
color: Color(0xFF333333),
|
||||
),
|
||||
systemOverlayStyle: SystemUiOverlayStyle.dark,
|
||||
toolbarTextStyle: TextTheme(
|
||||
headline6: TextStyle(
|
||||
color: const Color(0xFF333333),
|
||||
fontSize: 36.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
).bodyText2,
|
||||
titleTextStyle: TextTheme(
|
||||
headline6: TextStyle(
|
||||
color: const Color(0xFF333333),
|
||||
fontSize: 36.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
).headline6,
|
||||
),
|
||||
tabBarTheme: TabBarTheme(
|
||||
labelColor: const Color(0xFF333333),
|
||||
labelStyle: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
fontWeight: FontWeight.w600,
|
||||
),
|
||||
unselectedLabelStyle: TextStyle(
|
||||
fontSize: 28.sp,
|
||||
),
|
||||
indicatorSize: TabBarIndicatorSize.label,
|
||||
),
|
||||
bottomNavigationBarTheme: const BottomNavigationBarThemeData(
|
||||
selectedItemColor: Color(0xFF333333),
|
||||
selectedLabelStyle: TextStyle(
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
type: BottomNavigationBarType.fixed,
|
||||
unselectedLabelStyle: TextStyle(),
|
||||
),
|
||||
radioTheme: RadioThemeData(
|
||||
fillColor: MaterialStateProperty.resolveWith<Color?>((states) {
|
||||
if (states.contains(MaterialState.selected)) {
|
||||
return const Color(0xFFFFD000);
|
||||
}
|
||||
return null;
|
||||
}),
|
||||
),
|
||||
elevatedButtonTheme: ElevatedButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
backgroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return const Color(0xFFFFF4D7);
|
||||
}
|
||||
return const Color(0xFFFFD000);
|
||||
}),
|
||||
elevation: MaterialStateProperty.all(0),
|
||||
foregroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return const Color(0xFF666666);
|
||||
}
|
||||
return const Color(0xFF333333);
|
||||
}),
|
||||
textStyle: MaterialStateProperty.all(TextStyle(
|
||||
fontSize: 32.sp,
|
||||
fontWeight: FontWeight.bold,
|
||||
)),
|
||||
padding: MaterialStateProperty.all(
|
||||
EdgeInsets.symmetric(horizontal: 76.w, vertical: 22.w),
|
||||
),
|
||||
enableFeedback: true,
|
||||
),
|
||||
),
|
||||
textButtonTheme: TextButtonThemeData(
|
||||
style: ButtonStyle(
|
||||
overlayColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return const Color(0xFFFFF4D7);
|
||||
}
|
||||
return const Color(0xFFFFD000).withOpacity(0.2);
|
||||
}),
|
||||
foregroundColor: MaterialStateProperty.resolveWith((states) {
|
||||
if (states.contains(MaterialState.disabled)) {
|
||||
return const Color(0xFF666666);
|
||||
}
|
||||
return const Color(0xFF333333);
|
||||
}),
|
||||
),
|
||||
),
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
dividerColor: const Color(0xFFE8E8E8),
|
||||
colorScheme: ColorScheme.fromSwatch()
|
||||
.copyWith(secondary: const Color(0xFF027AFF))
|
||||
.copyWith(secondary: const Color(0xFF027AFF)),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SystemStyle {
|
||||
static const initial = SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarColor: Colors.white,
|
||||
);
|
||||
|
||||
static const yellowBottomBar = SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarColor: Color(0xFFFFD000),
|
||||
);
|
||||
|
||||
static genStyle({required Color bottom}) {
|
||||
return SystemUiOverlayStyle(
|
||||
statusBarIconBrightness: Brightness.light,
|
||||
systemNavigationBarColor: bottom,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@immutable
|
||||
class MyAppStyle extends ThemeExtension<MyAppStyle> {
|
||||
final TextStyle? bodyText3;
|
||||
final Color? mainColor;
|
||||
@override
|
||||
MyAppStyle copyWith({Color? mainColor, TextStyle? bodyText3}) {
|
||||
return MyAppStyle(
|
||||
mainColor: mainColor ?? this.mainColor,
|
||||
bodyText3: bodyText3 ?? this.bodyText3);
|
||||
}
|
||||
|
||||
@override
|
||||
ThemeExtension<MyAppStyle> lerp(ThemeExtension<MyAppStyle>? other, double t) {
|
||||
if (other is! MyAppStyle) {
|
||||
return this;
|
||||
}
|
||||
return MyAppStyle(
|
||||
mainColor: Color.lerp(mainColor, other.mainColor, t),
|
||||
bodyText3: TextStyle.lerp(bodyText3, other.bodyText3, t),
|
||||
);
|
||||
}
|
||||
|
||||
const MyAppStyle({
|
||||
this.bodyText3,
|
||||
this.mainColor,
|
||||
});
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class LoginPage extends StatefulWidget {
|
||||
const LoginPage({super.key});
|
||||
|
||||
@override
|
||||
_LoginPageState createState() => _LoginPageState();
|
||||
}
|
||||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
import 'package:cloud_car_internal/ui/login/login_page.dart';
|
||||
import 'package:cloud_car_internal/ui/tab_navigator.dart';
|
||||
import 'package:cloud_car_internal/utils/hive_util.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
import '../../constants/environment/environment.dart';
|
||||
import '../../providers/user_provider.dart';
|
||||
|
||||
class SplashPage extends StatefulWidget {
|
||||
const SplashPage({super.key});
|
||||
|
||||
@override
|
||||
_SplashPageState createState() => _SplashPageState();
|
||||
}
|
||||
|
||||
class _SplashPageState extends State<SplashPage> {
|
||||
final TapGestureRecognizer _agreementRecognizer = TapGestureRecognizer();
|
||||
final TapGestureRecognizer _privacyRecognizer = TapGestureRecognizer();
|
||||
|
||||
Future initialAll() async {
|
||||
///第三方加载
|
||||
await HiveUtil.init();
|
||||
// var agreement = await HiveStore.appBox?.get('agreement') ?? false;
|
||||
// if (!agreement) {
|
||||
// var result = await _showLoginVerify();
|
||||
// if (result == null || !result) {
|
||||
// await SystemNavigator.pop();
|
||||
// await HiveStore.appBox?.put('agreement', false);
|
||||
// } else {
|
||||
// await HiveStore.appBox?.put('agreement', true);
|
||||
// }
|
||||
// }
|
||||
///Providers 初始化
|
||||
}
|
||||
|
||||
Future<bool?> _showLoginVerify() async {
|
||||
return await showCupertinoDialog(
|
||||
barrierDismissible: false,
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return CupertinoAlertDialog(
|
||||
title: const Text('隐私政策和用户协议'),
|
||||
content: RichText(
|
||||
text: TextSpan(
|
||||
text: '点击登录即表示您已阅读并同意',
|
||||
style: const TextStyle(color: Colors.black),
|
||||
children: [
|
||||
TextSpan(
|
||||
text: '《用户协议》',
|
||||
style: const TextStyle(color: Colors.blue),
|
||||
recognizer: _agreementRecognizer
|
||||
..onTap = () {
|
||||
// Get.to(() => AgreementPage());
|
||||
}),
|
||||
TextSpan(
|
||||
text: '《隐私政策》',
|
||||
style: const TextStyle(color: Colors.blue),
|
||||
recognizer: _privacyRecognizer
|
||||
..onTap = () {
|
||||
// Get.to(() => PrivacyPage());
|
||||
}),
|
||||
const TextSpan(
|
||||
style: TextStyle(color: Colors.black),
|
||||
text:
|
||||
'(特别是免除或限制责任、管辖等粗体下划线标注的条款)。如您不同意上述协议的任何条款,您应立即停止登录及使用本软件及服务。')
|
||||
]),
|
||||
),
|
||||
|
||||
// ),
|
||||
actions: [
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Get.back(result: true),
|
||||
child: const Text('同意'),
|
||||
),
|
||||
CupertinoDialogAction(
|
||||
onPressed: () => Get.back(result: false),
|
||||
child: const Text('拒绝'),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
final userProvider = Provider.of<UserProvider>(context, listen: false);
|
||||
var env = const String.fromEnvironment('ENV', defaultValue: 'dev');
|
||||
if (kDebugMode) {
|
||||
print('env :$env');
|
||||
}
|
||||
DevEV.instance.setEnvironment( context, environment: env == 'dev',);
|
||||
Future.delayed(const Duration(milliseconds: 1000), () async {
|
||||
await initialAll();
|
||||
if (!await userProvider.init()) {
|
||||
await Get.offAll(() => const LoginPage());
|
||||
} else {
|
||||
await Get.offAll(() => const TabNavigator());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return const Scaffold(
|
||||
body: Center(
|
||||
child: CircularProgressIndicator(),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class TabNavigator extends StatefulWidget {
|
||||
const TabNavigator({super.key});
|
||||
|
||||
@override
|
||||
_TabNavigatorState createState() => _TabNavigatorState();
|
||||
}
|
||||
|
||||
class _TabNavigatorState extends State<TabNavigator> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
class CloudBackButton extends StatelessWidget {
|
||||
final Color color;
|
||||
final bool isSpecial;
|
||||
|
||||
const CloudBackButton({
|
||||
super.key,
|
||||
this.color = const Color(0xFF111111),
|
||||
this.isSpecial = false,
|
||||
});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Navigator.canPop(context)
|
||||
? Padding(
|
||||
padding: isSpecial ? EdgeInsets.only(left: 8.w) : EdgeInsets.zero,
|
||||
child: IconButton(
|
||||
onPressed: () => Get.back(),
|
||||
icon: Icon(
|
||||
CupertinoIcons.chevron_back,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
)
|
||||
: const SizedBox();
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
import 'package:cloud_car_internal/utils/user_tool.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class CloudBottomButton extends StatefulWidget {
|
||||
final String text;
|
||||
final BoxDecoration? decoration;
|
||||
final Function() onTap;
|
||||
const CloudBottomButton({
|
||||
super.key,
|
||||
this.text = '返回首页',
|
||||
required this.onTap, this.decoration,
|
||||
});
|
||||
|
||||
@override
|
||||
State<CloudBottomButton> createState() => _CloudBottomButtonState();
|
||||
}
|
||||
|
||||
class _CloudBottomButtonState extends State<CloudBottomButton> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap:widget.onTap,
|
||||
child: Material(
|
||||
color:Colors.transparent,
|
||||
child: Container(
|
||||
alignment: Alignment.center,
|
||||
padding: EdgeInsets.symmetric(vertical: 15.w),
|
||||
margin: EdgeInsets.symmetric(horizontal: 32.w),
|
||||
decoration:widget.decoration?? UserTool.myAppStyle.bottomButtonDecoration!,
|
||||
child: Text(
|
||||
widget.text,
|
||||
style: UserTool.myAppStyle.bottomButtonText,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
|
||||
import 'package:cloud_car_internal/constants/app_theme.dart';
|
||||
import 'package:cloud_car_internal/widget/buttons/cloud_back_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
|
||||
class CloudScaffold extends StatelessWidget {
|
||||
final Widget? body;
|
||||
final Widget? appbar;
|
||||
final Color bodyColor;
|
||||
final Widget? bottomNavi;
|
||||
final FloatingActionButton? fab;
|
||||
final bool extendBody;
|
||||
final String? path;
|
||||
final SystemUiOverlayStyle systemStyle;
|
||||
final String? title;
|
||||
final List<Widget> actions;
|
||||
final Color? appBarBackColor;
|
||||
final PreferredSizeWidget? appBarBottom;
|
||||
final Widget? endDrawer;
|
||||
|
||||
const CloudScaffold(
|
||||
{super.key,
|
||||
this.body,
|
||||
this.appbar,
|
||||
this.bodyColor = const Color(0xFFF9F9F9),
|
||||
this.bottomNavi,
|
||||
this.fab,
|
||||
this.systemStyle = SystemStyle.initial,
|
||||
this.extendBody = false,
|
||||
this.path,
|
||||
this.title,
|
||||
this.appBarBackColor = Colors.white,
|
||||
this.appBarBottom,
|
||||
this.actions = const [],
|
||||
this.endDrawer})
|
||||
: assert(title != null || appbar != null);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.light);
|
||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||
value: systemStyle,
|
||||
child: Scaffold(
|
||||
endDrawer: endDrawer,
|
||||
backgroundColor: bodyColor,
|
||||
extendBodyBehindAppBar: extendBody,
|
||||
extendBody: extendBody,
|
||||
body: body,
|
||||
appBar: PreferredSize(
|
||||
preferredSize: Size.fromHeight(176.w),
|
||||
child: title == null
|
||||
? appbar!
|
||||
: AppBar(
|
||||
bottom: appBarBottom,
|
||||
backgroundColor:
|
||||
extendBody ? Colors.transparent : appBarBackColor,
|
||||
leading: const CloudBackButton(),
|
||||
title: Text(
|
||||
title!,
|
||||
style: TextStyle(
|
||||
color: Colors.black,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontSize: 32.sp),
|
||||
),
|
||||
actions: actions,
|
||||
),
|
||||
),
|
||||
bottomNavigationBar: bottomNavi,
|
||||
floatingActionButton: fab,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue