Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 3.25 KB | None | 0 0
  1. //PUSH DAL LOGIN
  2. Navigator.pushReplacementNamed(context, '/home');
  3.  
  4. //MYAPPSTATE
  5. @override
  6.   void initState() {
  7.     _checkInternetConnection();
  8.     SystemChrome.restoreSystemUIOverlays();
  9.     _model.autoLog();
  10.     //_internalStorage.initHive();
  11.     _model.authenticated.listen((bool isAuthenticated) {
  12.       _isAuthenticated = isAuthenticated;
  13.       print('Autenticato: $_isAuthenticated');
  14.       if (_isAuthenticated) {
  15.         _initPlatformConfiguration(context, _model);
  16.         _initFetch();
  17.       }
  18.     });
  19.     super.initState();
  20.   }
  21.  
  22.   // Esegue il fetch dei dati fondamentali dalle Api di Argo,
  23.   // aggiorna lo storage e fetcha gli articoli dal sito della scuola
  24.   Future<Null> _initFetch() async {
  25.     await _model.totalFetch();
  26.     await _model.temporaryStorage();
  27.     //await _model.fetchArticle();
  28.   }
  29.  
  30.   @override
  31.   Widget build(BuildContext context) {
  32.     return ScopedModel<MainModel>(
  33.         model: _model,
  34.         child: DynamicTheme(
  35.           defaultBrightness: Brightness.light,
  36.           data: (Brightness brightness) => ThemeData(
  37.            /////TEMA
  38.           ),
  39.           themedWidgetBuilder: (BuildContext context, ThemeData theme) {
  40.             return MaterialApp(
  41.               //debugShowMaterialGrid: true,
  42.               //showPerformanceOverlay: true,
  43.               //showSemanticsDebugger: true,
  44.               debugShowCheckedModeBanner: false,
  45.               title: 'Book',
  46.               //In caso DynamicTheme non dovesse funzionare sostituire
  47.               // theme con ThemeData e il suo contenuto
  48.               theme: theme,
  49.               routes: {
  50.                 '/': (BuildContext context) =>
  51.                     !_isAuthenticated ? Login() : SplashPage(_model),
  52.                 '/login': (BuildContext context) => Login(),
  53.                 '/home': (BuildContext context) => Overview(_model),
  54.                 '/splash': (BuildContext context) => SplashPage(_model),
  55.                 '/focus': (BuildContext context) => FocusPage(),
  56.                 '/profile': (BuildContext context) => Profile(),
  57.                 '/absence': (BuildContext context) => Absences(),
  58.                 '/votes': (BuildContext context) => VotesPage(),
  59.                 '/homework': (BuildContext context) => HomeworkPage(),
  60.                 '/lessons': (BuildContext context) => LessonsPage(),
  61.                 '/timeSheet': (BuildContext context) => TimeSheet(),
  62.                 '/more': (BuildContext context) => MorePage(_model),
  63.                 '/notes': (BuildContext context) => NotesPage(_model),
  64.                 '/memo': (BuildContext context) => ClassMemoPage(_model),
  65.                 '/info': (BuildContext context) => InfoPage(),
  66.               },
  67.               //initialRoute: '/splash',
  68.               onGenerateRoute: (RouteSettings settings) {
  69.                 return MaterialPageRoute(
  70.                     builder: (BuildContext context) =>
  71.                         !_isAuthenticated ? Login() : Overview(_model));
  72.               },
  73.               onUnknownRoute: (RouteSettings settings) {
  74.                 return MaterialPageRoute(
  75.                     builder: (BuildContext context) =>
  76.                         !_isAuthenticated ? Login() : Overview(_model));
  77.               },
  78.             );
  79.           },
  80.         ));
  81.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement