import 'package:fluro/fluro.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:provider/provider.dart';
import 'package:sport/pages/home_page.dart';
import 'package:sport/provider/bluetooth.dart';
import 'package:sport/provider/message_model.dart';
import 'package:sport/utils/CupertinoLocalizationsDelegate.dart';

import 'application.dart';
import 'provider/user_model.dart';
import 'router/routes.dart';

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final router = Router();
    Routes.configureRoutes(router);
    Application.router = router;

    return MultiProvider(
      providers: [
        ChangeNotifierProvider<UserModel>(
          create: (_) => UserModel(),
        ),
        ChangeNotifierProvider<Bluetooth>(
          create: (_) => Bluetooth(),
        ),
        ChangeNotifierProvider<MessageModel>(
          create: (_) => MessageModel(),
        ),
      ],
      child: MaterialApp(
        debugShowCheckedModeBanner: false,
        // title: 'Flutter Demo',
        onGenerateRoute: Application.router.generator,
        localizationsDelegates: [
          CupertinoLocalizationsDelegate(),
          GlobalMaterialLocalizations.delegate,
          GlobalWidgetsLocalizations.delegate,
        ],
        supportedLocales: [const Locale('zh', 'CH'), const Locale('en', 'US')],
        navigatorObservers: [routeObserver],
        theme: ThemeData(
            platform: TargetPlatform.iOS,
            brightness: Brightness.light,
            primaryColor: Colors.white,
            accentColor: Color(0xffFFC400),
//            splashColor: Colors.transparent,
            backgroundColor: Color(0xffF1F1F1),
            scaffoldBackgroundColor: Color(0xffF1F1F1),
            textTheme: TextTheme(
              headline1: TextStyle(fontSize: 18.0, color: Color(0xff333333), fontWeight: FontWeight.w600),
              headline2: TextStyle(fontSize: 25.0, color: Color(0xff333333), fontWeight: FontWeight.w600),
              headline3: TextStyle(fontSize: 16.0, color: Color(0xff333333), fontWeight: FontWeight.w600),
              headline4: TextStyle(fontSize: 16.0, color: Color(0xffffffff), fontWeight: FontWeight.w600),
              headline6: TextStyle(fontSize: 14.0, color: Color(0xffffffff), fontWeight: FontWeight.normal),
              subtitle1: TextStyle(fontSize: 14.0, color: Color(0xff333333), fontWeight: FontWeight.normal),
              subtitle2: TextStyle(fontSize: 12.0, color: Color(0xff333333), fontWeight: FontWeight.normal),
              bodyText1: TextStyle(fontSize: 12.0, color: Color(0xff999999), fontWeight: FontWeight.normal),
              bodyText2: TextStyle(fontSize: 14.0, color: Color(0xff999999), fontWeight: FontWeight.normal),
            ),
            dividerTheme: DividerThemeData(color: Color(0xffDCDCDC)),
            tabBarTheme: TabBarTheme(
                indicatorSize: TabBarIndicatorSize.label,
                labelColor: Color(0xffFFC400),
                unselectedLabelColor: Color(0xff333333),
                labelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600),
                unselectedLabelStyle: TextStyle(fontSize: 16.0, fontWeight: FontWeight.w600)),
            appBarTheme: AppBarTheme(
              elevation: 0,
            ),
            popupMenuTheme: PopupMenuThemeData(textStyle:TextStyle(fontSize: 14.0, color: Color(0xff666666), fontWeight: FontWeight.normal), shape: RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(10.0))))),

        home: HomePage(),
      ),
    );
  }
}
