|
|
|
import 'dart:io';
|
|
|
|
import 'dart:ui';
|
|
|
|
|
|
|
|
import 'package:event_bus/event_bus.dart';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
import 'package:huixiang/address/address_map_page.dart';
|
|
|
|
import 'package:huixiang/address/edit_address_page.dart';
|
|
|
|
import 'package:huixiang/article/hot_article_details_page.dart';
|
|
|
|
import 'package:huixiang/article/hot_article_item.dart';
|
|
|
|
import 'package:huixiang/article/video_playback_page.dart';
|
|
|
|
import 'package:huixiang/generated/l10n.dart';
|
|
|
|
import 'package:huixiang/home/founder_story_page.dart';
|
|
|
|
import 'package:huixiang/integral/integral_detailed_page.dart';
|
|
|
|
import 'package:huixiang/integral/integral_page.dart';
|
|
|
|
import 'package:huixiang/integral_store/integral_store_details_page.dart';
|
|
|
|
import 'package:huixiang/login/login_page.dart';
|
|
|
|
import 'package:huixiang/message/main_message_page.dart';
|
|
|
|
import 'package:huixiang/message/system_message.dart';
|
|
|
|
import 'package:huixiang/mine/coupons_page.dart';
|
|
|
|
import 'package:huixiang/mine/edit_name.dart';
|
|
|
|
import 'package:huixiang/mine/mine_card_invalid_page.dart';
|
|
|
|
import 'package:huixiang/mine/mine_card_page.dart';
|
|
|
|
import 'package:huixiang/mine/mine_vip_level_page.dart';
|
|
|
|
import 'package:huixiang/mine/mine_wallet_page.dart';
|
|
|
|
import 'package:huixiang/mine/recharge_page.dart';
|
|
|
|
import 'package:huixiang/mine/user_info_page.dart';
|
|
|
|
import 'package:huixiang/mine/vip_balance_page.dart';
|
|
|
|
import 'package:huixiang/mine/vip_card_page.dart';
|
|
|
|
import 'package:huixiang/mine/vip_detail_page.dart';
|
|
|
|
import 'package:huixiang/order/edit_remarks_page.dart';
|
|
|
|
import 'package:huixiang/order/exchange_history_page.dart';
|
|
|
|
import 'package:huixiang/order/exchange_order_page.dart';
|
|
|
|
import 'package:huixiang/order/exchange_order_success_page.dart';
|
|
|
|
import 'package:huixiang/order/exchange_order_detail_page.dart';
|
|
|
|
import 'package:huixiang/order/logistics_information_page.dart';
|
|
|
|
import 'package:huixiang/order/order_detail_page.dart';
|
|
|
|
import 'package:huixiang/order/order_history_page.dart';
|
|
|
|
import 'package:huixiang/order/store_selector_page.dart';
|
|
|
|
import 'package:huixiang/order/write_off_page.dart';
|
|
|
|
import 'package:huixiang/order/write_off_success_page.dart';
|
|
|
|
import 'package:huixiang/setting/about_page.dart';
|
|
|
|
import 'package:huixiang/setting/help_feedback_page.dart';
|
|
|
|
import 'package:huixiang/setting/permission_setting_page.dart';
|
|
|
|
import 'package:huixiang/setting/setting_page.dart';
|
|
|
|
|
|
|
|
// import 'package:huixiang/ui_test.dart';
|
|
|
|
import 'package:huixiang/union/store_details_page.dart';
|
|
|
|
import 'package:huixiang/union/union_details_page.dart';
|
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
|
|
|
|
import 'main_page.dart';
|
|
|
|
import 'mine/manage_address_page.dart';
|
|
|
|
import 'mine/roll_center_page.dart';
|
|
|
|
|
|
|
|
void main() async {
|
|
|
|
if (Platform.isAndroid) {
|
|
|
|
SystemChrome.setSystemUIOverlayStyle(
|
|
|
|
SystemUiOverlayStyle(statusBarColor: Colors.transparent));
|
|
|
|
}
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
SystemChrome.setPreferredOrientations([
|
|
|
|
DeviceOrientation.portraitUp,
|
|
|
|
]);
|
|
|
|
SharedPreferences sharedPreferences = await SharedPreferences.getInstance();
|
|
|
|
Locale locale;
|
|
|
|
if (sharedPreferences.containsKey("language") &&
|
|
|
|
sharedPreferences.getString("language") == "zh") {
|
|
|
|
locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'CN');
|
|
|
|
} else {
|
|
|
|
locale = Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW');
|
|
|
|
}
|
|
|
|
runApp(MyApp(locale));
|
|
|
|
}
|
|
|
|
|
|
|
|
EventBus eventBus = EventBus(sync: true);
|
|
|
|
|
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
final Locale appLocale;
|
|
|
|
|
|
|
|
MyApp(this.appLocale);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return ScreenUtilInit(
|
|
|
|
designSize: Size(375, 812),
|
|
|
|
builder: () => MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
theme: ThemeData(
|
|
|
|
primarySwatch: Colors.blue,
|
|
|
|
textTheme: TextTheme(
|
|
|
|
button: TextStyle(fontSize: 24.sp),
|
|
|
|
bodyText1: TextStyle(fontSize: 12.sp),
|
|
|
|
bodyText2: TextStyle(fontSize: 16.sp),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
// locale: locale,
|
|
|
|
localeResolutionCallback: (locale, supportedLocales) {
|
|
|
|
print("locale: $locale");
|
|
|
|
print("supportedLocales: $supportedLocales");
|
|
|
|
// Localizations.maybeLocaleOf(context)
|
|
|
|
|
|
|
|
return appLocale ??
|
|
|
|
Locale.fromSubtags(languageCode: 'zh', countryCode: 'TW');
|
|
|
|
},
|
|
|
|
localizationsDelegates: [
|
|
|
|
GlobalMaterialLocalizations.delegate,
|
|
|
|
GlobalCupertinoLocalizations.delegate,
|
|
|
|
GlobalWidgetsLocalizations.delegate,
|
|
|
|
S.delegate
|
|
|
|
],
|
|
|
|
supportedLocales: S.delegate.supportedLocales,
|
|
|
|
home: LoginPage(),
|
|
|
|
builder: (context, widget) {
|
|
|
|
double textScaleFactor = MediaQuery.of(context).textScaleFactor;
|
|
|
|
print("textScaleFactor: $textScaleFactor");
|
|
|
|
return MediaQuery(
|
|
|
|
data: MediaQuery.of(context).copyWith(
|
|
|
|
textScaleFactor: textScaleFactor > 1.15 ? 1.15 : textScaleFactor,
|
|
|
|
// devicePixelRatio: devicePixelRatio * textScaleFactor
|
|
|
|
),
|
|
|
|
child: widget,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
onGenerateRoute: (settings) {
|
|
|
|
final String name = settings.name;
|
|
|
|
final Function pageContentBuilder = routers[name];
|
|
|
|
if (pageContentBuilder != null) {
|
|
|
|
final Route route = MaterialPageRoute(
|
|
|
|
builder: (context) {
|
|
|
|
return pageContentBuilder(context,
|
|
|
|
arguments: settings.arguments);
|
|
|
|
},
|
|
|
|
settings: settings,
|
|
|
|
);
|
|
|
|
return route;
|
|
|
|
}
|
|
|
|
return MaterialPageRoute(
|
|
|
|
//未找到页面配置进入登录页
|
|
|
|
builder: (context) {
|
|
|
|
return LoginPage();
|
|
|
|
},
|
|
|
|
settings: settings,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Map<String, WidgetBuilder> routers = <String, WidgetBuilder>{
|
|
|
|
'/router/main_page': (context, {arguments}) => MainPage(),
|
|
|
|
'/router/msg_page': (context, {arguments}) => MainMessagePage(),
|
|
|
|
'/router/system_msg_page': (context, {arguments}) => SystemMessagePage(),
|
|
|
|
'/router/exchange_order_details': (context, {arguments}) =>
|
|
|
|
ExchangeOrderDetailPage(),
|
|
|
|
'/router/integral_page': (context, {arguments}) => IntegralPage(),
|
|
|
|
'/router/integral_detailed_page': (context, {arguments}) =>
|
|
|
|
IntegralDetailedPage(),
|
|
|
|
'/router/mine_wallet': (context, {arguments}) => MineWalletPage(),
|
|
|
|
'/router/user_info_page': (context, {arguments}) => UserInfoPage(),
|
|
|
|
'/router/mine_card': (context, {arguments}) => MineCardPage(),
|
|
|
|
'/router/mine_card_invalid': (context, {arguments}) => MineCardInvalidPage(),
|
|
|
|
'/router/vip_card_page': (context, {arguments}) => VipCardPage(),
|
|
|
|
'/router/vip_details_page': (context, {arguments}) => VipDetailPage(arguments: arguments),
|
|
|
|
'/router/vip_balance': (context, {arguments}) => VipBalancePage(),
|
|
|
|
'/router/coupons_page': (context, {arguments}) => CouponsPage(),
|
|
|
|
'/router/permission_setting': (context, {arguments}) =>
|
|
|
|
PermissionSettingPage(),
|
|
|
|
'/router/manage_address_page': (context, {arguments}) =>
|
|
|
|
ManageAddressPage(arguments: arguments),
|
|
|
|
'/router/setting_page': (context, {arguments}) => SettingPage(),
|
|
|
|
'/router/about_page': (context, {arguments}) => AboutPage(),
|
|
|
|
'/router/help_feedback_page': (context, {arguments}) => HelpFeedbackPage(),
|
|
|
|
'/router/union_detail_page': (context, {arguments}) =>
|
|
|
|
UnionDetailsPage(arguments: arguments),
|
|
|
|
'/router/store_detail_page': (context, {arguments}) =>
|
|
|
|
StoreDetailsPage(arguments: arguments),
|
|
|
|
'/router/integral_store_page': (context, {arguments}) =>
|
|
|
|
IntegralStoreDetailsPage(
|
|
|
|
arguments: arguments,
|
|
|
|
),
|
|
|
|
'/router/exchange_order_page': (context, {arguments}) => ExchangeOrderPage(
|
|
|
|
arguments: arguments,
|
|
|
|
),
|
|
|
|
'/router/store_selector_page': (context, {arguments}) => StoreSelectorPage(),
|
|
|
|
'/router/exchange_order_success_page': (context, {arguments}) =>
|
|
|
|
ExchangeOrderSuccessPage(
|
|
|
|
arguments: arguments,
|
|
|
|
),
|
|
|
|
'/router/mine_vip_level_page': (context, {arguments}) => MineVipLevelPage(arguments:arguments),
|
|
|
|
'/router/exchange_history_page': (context, {arguments}) =>
|
|
|
|
ExchangeHistoryPage(),
|
|
|
|
'/router/write_off_page': (context, {arguments}) => WriteOffPage(),
|
|
|
|
'/router/write_off_success_page': (context, {arguments}) =>
|
|
|
|
WriteOffSuccessPage(),
|
|
|
|
'/router/order_history_page': (context, {arguments}) => OrderHistoryPage(),
|
|
|
|
'/router/order_details': (context, {arguments}) => OrderDetailPage(arguments: arguments),
|
|
|
|
'/router/recharge_page': (context, {arguments}) => RechargePage(),
|
|
|
|
'/router/hot_article_page': (context, {arguments}) => HotArticlePage(),
|
|
|
|
'/router/address_edit_page': (context, {arguments}) => EditAddressPage(
|
|
|
|
arguments: arguments,
|
|
|
|
),
|
|
|
|
'/router/address_map_page': (context, {arguments}) => AddressMapPage(),
|
|
|
|
'/router/logistics_information_page': (context, {arguments}) =>
|
|
|
|
LogisticsInformationPage(),
|
|
|
|
'/router/hot_article_details_page': (context, {arguments}) =>
|
|
|
|
HotArticleDetailsPage(),
|
|
|
|
'/router/founder_story_page': (context, {arguments}) => FounderStoryPage(),
|
|
|
|
'/router/video_playback_page': (context, {arguments}) => VideoPlaybackPage(),
|
|
|
|
'/router/roll_center_page': (context, {arguments}) => RollCenterPage(),
|
|
|
|
'/router/edit_remarks_page': (context, {arguments}) => EditRemarksPage(),
|
|
|
|
'/router/edit_name': (context, {arguments}) => EditName(
|
|
|
|
arguments: arguments,
|
|
|
|
),
|
|
|
|
// '/router/hot_article_details_page': (context, {arguments}) => HotArticleDetailsPage(),
|
|
|
|
// '/router/ui_test': (context, {arguments}) => UITest(),
|
|
|
|
};
|