diff --git a/lib/main.dart b/lib/main.dart index c4cafc8..13731a7 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -81,7 +81,7 @@ class FlwtchState extends State { @override Widget build(BuildContext context) { //appStatus = AppModel(cwtch: cwtch); - + globalSettings.initPackageInfo(); return MultiProvider( providers: [ getFlwtchStateProvider(), @@ -91,15 +91,14 @@ class FlwtchState extends State { getTorStatusProvider(), ], builder: (context, widget) { - Provider.of(context).initPackageInfo(); return Consumer( - builder: (context, opaque, child) => MaterialApp( + builder: (context, settings, child) => MaterialApp( key: Key('app'), - locale: Provider.of(context).locale, + locale: settings.locale, localizationsDelegates: AppLocalizations.localizationsDelegates, supportedLocales: AppLocalizations.supportedLocales, title: 'Cwtch', - theme: mkThemeData(opaque), + theme: mkThemeData(settings), // from dan: home: cwtchInit == true ? ProfileMgrView(cwtch) : SplashView(), // from erinn: home: columns.length == 3 ? TripleColumnView() : ProfileMgrView(), home: cwtchInit == true ? (columns.length == 3 ? TripleColumnView() : ProfileMgrView()) : SplashView(), diff --git a/lib/views/profilemgrview.dart b/lib/views/profilemgrview.dart index a45edfe..b458123 100644 --- a/lib/views/profilemgrview.dart +++ b/lib/views/profilemgrview.dart @@ -31,36 +31,38 @@ class _ProfileMgrViewState extends State { @override Widget build(BuildContext context) { - // Prevents Android back button from closing the app on the profile manager screen - // (which would shutdown connections and all kinds of other expensive to generate things) - // TODO pop up a dialogue regarding closing the app? - return new WillPopScope( - onWillPop: () async => false, - child: Scaffold( - backgroundColor: Provider.of(context).theme.backgroundMainColor(), - appBar: AppBar( - title: Text(AppLocalizations.of(context)!.titleManageProfiles), - actions: [ - IconButton(icon: TorIcon(), onPressed: _pushTorStatus), - IconButton(icon: Icon(Icons.bug_report_outlined), onPressed: _setLoggingLevelDebug), - IconButton( - icon: Icon(Icons.lock_open), - tooltip: AppLocalizations.of(context)!.tooltipUnlockProfiles, - onPressed: _modalUnlockProfiles, - ), - IconButton(icon: Icon(Icons.settings), tooltip: AppLocalizations.of(context)!.tooltipOpenSettings, onPressed: _pushGlobalSettings), - ], - ), - floatingActionButton: FloatingActionButton( - onPressed: _pushAddEditProfile, - tooltip: AppLocalizations.of(context)!.addNewProfileBtn, - child: Icon( - Icons.add, - semanticLabel: AppLocalizations.of(context)!.addNewProfileBtn, + return Consumer( + // Prevents Android back button from closing the app on the profile manager screen + // (which would shutdown connections and all kinds of other expensive to generate things) + // TODO pop up a dialogue regarding closing the app? + builder: (context, settings, child) => WillPopScope( + onWillPop: () async => false, + child: Scaffold( + backgroundColor: settings.theme.backgroundMainColor(), + appBar: AppBar( + title: Text(AppLocalizations.of(context)!.titleManageProfiles), + actions: [ + IconButton(icon: TorIcon(), onPressed: _pushTorStatus), + IconButton(icon: Icon(Icons.bug_report_outlined), onPressed: _setLoggingLevelDebug), + IconButton( + icon: Icon(Icons.lock_open), + tooltip: AppLocalizations.of(context)!.tooltipUnlockProfiles, + onPressed: _modalUnlockProfiles, + ), + IconButton(icon: Icon(Icons.settings), tooltip: AppLocalizations.of(context)!.tooltipOpenSettings, onPressed: _pushGlobalSettings), + ], ), - ), - body: _buildProfileManager(), //_buildSuggestions(), - )); + floatingActionButton: FloatingActionButton( + onPressed: _pushAddEditProfile, + tooltip: AppLocalizations.of(context)!.addNewProfileBtn, + child: Icon( + Icons.add, + semanticLabel: AppLocalizations.of(context)!.addNewProfileBtn, + ), + ), + body: _buildProfileManager(), + )), + ); } void _setLoggingLevelDebug() { @@ -154,28 +156,32 @@ class _ProfileMgrViewState extends State { } Widget _buildProfileManager() { - final tiles = Provider.of(context).profiles.map( - (ProfileInfoState profile) { - return ChangeNotifierProvider.value( - value: profile, - builder: (context, child) => RepaintBoundary(child: ProfileRow()), + return Consumer( + builder: (context, pls, child) { + final tiles = pls.profiles.map( + (ProfileInfoState profile) { + return ChangeNotifierProvider.value( + value: profile, + builder: (context, child) => RepaintBoundary(child: ProfileRow()), + ); + }, ); + + final divided = ListTile.divideTiles( + context: context, + tiles: tiles, + ).toList(); + + if (tiles.isEmpty) { + return const Center( + child: const Text( + "Please create or unlock a profile to begin!", + textAlign: TextAlign.center, + )); + } + + return ListView(children: divided); }, ); - - final divided = ListTile.divideTiles( - context: context, - tiles: tiles, - ).toList(); - - if (tiles.isEmpty) { - return Center( - child: Text( - "Please create or unlock a profile to begin!", - textAlign: TextAlign.center, - )); - } - - return ListView(children: divided); } } diff --git a/lib/views/splashView.dart b/lib/views/splashView.dart index 5ec073f..3b18b5d 100644 --- a/lib/views/splashView.dart +++ b/lib/views/splashView.dart @@ -4,10 +4,8 @@ import 'package:flutter/material.dart'; class SplashView extends StatelessWidget { @override Widget build(BuildContext context) { - print("SplashView build()"); - return Scaffold( - appBar: AppBar(title: Text("Cwtch")), - body: Center(child: Column(children: [Text("Loading Cwtch...")])), + return const Scaffold( + body: const Center(child: const Text("Loading Cwtch...")), ); } }