import 'package:flutter/material.dart';
import 'package:flutter_habit/provider/ConfigProvider.dart';
import 'package:flutter_habit/provider/DataProvider.dart';
import 'package:flutter_habit/provider/UserProvider.dart';
import 'package:flutter_habit/pages/splash_page.dart';
import 'package:provider/provider.dart';

import 'provider/NotificationProvider.dart';
import 'provider/ThemeProvider.dart';

void main() {
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider<ThemeProvider>(
          create: (_) => ThemeProvider(),
        ),
        ChangeNotifierProvider<UserProvider>(
          create: (_) => UserProvider(),
        ),
        ChangeNotifierProvider<DataProvider>(
          create: (_) => DataProvider(),
        ),
        ChangeNotifierProvider<ConfigProvider>(
          create: (_) => ConfigProvider(),
        ),
        ChangeNotifierProvider<NotificationProvider>(
          create: (_) => NotificationProvider(),
        ),
      ],
      child: MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Habit',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Provider.of<ThemeProvider>(context).currentMaterialColor,
        brightness: Provider.of<ThemeProvider>(context).currentBrightness,
      ),
      home: LoadingPage(),
    );
  }
}
