Skip to content

Commit

Permalink
add admin panel to developer accounts
Browse files Browse the repository at this point in the history
  • Loading branch information
NeXTormer committed Mar 8, 2024
1 parent d25cb76 commit f8a772d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
43 changes: 22 additions & 21 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'package:frederic/backend/sets/frederic_set_document.dart';
import 'package:frederic/backend/sets/frederic_set_manager.dart';
import 'package:frederic/backend/sets/set_time_series_data_representation.dart';
import 'package:frederic/backend/util/frederic_profiler.dart';
import 'package:frederic/frederic_admin_panel.dart';
import 'package:frederic/frederic_main_app.dart';
import 'package:frederic/theme/frederic_theme.dart';
import 'package:get_it/get_it.dart';
Expand All @@ -27,6 +28,9 @@ import 'package:shared_preferences/shared_preferences.dart';
import 'package:sheet/route.dart';
import 'package:system_theme/system_theme.dart';

import 'admin_panel/backend/admin_backend.dart';
import 'admin_panel/backend/admin_icon_manager.dart';

final getIt = GetIt.instance;

FredericColorTheme _colorTheme = FredericColorTheme.blue();
Expand Down Expand Up @@ -68,8 +72,6 @@ void main() async {
);
}).sendPort);

// == Record all errors within a Flutter context ==
//runZonedGuarded<Future<void>>(() async { //TODO: fix zone error or remove completely
await EasyLocalization.ensureInitialized();

// == Crashlytics & Performance ==
Expand Down Expand Up @@ -103,8 +105,6 @@ void main() async {
Hive.registerAdapter(TimestampTypeAdapter()); // typeId: 100
// == Hive == End ==

//await Hive.deleteBoxFromDisk('SetVolumeDataRepresentation');

// == Load Startup Preferences ==
SharedPreferences preferences = await SharedPreferences.getInstance();
Object? themeID = preferences.get('colortheme');
Expand All @@ -129,8 +129,6 @@ void main() async {
useOnlyLangCode: true,
path: 'assets/translations',
child: FredericBase()));

//}, (error, stack) => FirebaseCrashlytics.instance.recordError(error, stack));
}

class FredericBase extends StatefulWidget {
Expand Down Expand Up @@ -219,23 +217,26 @@ class _FredericBaseState extends State<FredericBase> {
},
);
}
if (settings.name == '/admin') {
if (getIt.isRegistered<AdminBackend>())
getIt.unregister<AdminBackend>();
getIt.registerSingleton<AdminBackend>(AdminBackend());

return MaterialExtendedPageRoute<void>(
builder: (BuildContext context) {
return OrientationBuilder(builder: (context, orientation) {
if (orientation == Orientation.portrait) {
return FredericMainApp();
}
return BlocProvider<AdminIconManager>.value(
value: AdminBackend.instance.iconManager,
child: FredericAdminPanel());
});
},
);
}
return null;
},
// home: FredericMainApp()
// OrientationBuilder(
// builder: (context, orientation) {
// if (orientation == Orientation.portrait) {
// return FredericMainApp();
// }
//
// if (getIt.isRegistered<AdminBackend>())
// getIt.unregister<AdminBackend>();
// getIt.registerSingleton<AdminBackend>(AdminBackend());
// return BlocProvider<AdminIconManager>.value(
// value: AdminBackend.instance.iconManager,
// child: FredericAdminPanel());
// },
// ),
),
),
);
Expand Down
5 changes: 5 additions & 0 deletions lib/screens/settings_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ class SettingsScreen extends StatelessWidget {
changerTitle: 'Debug logs',
changeAttributeWidget: FredericProfiler.showLogsAsWidget(),
),
SettingsElement(
text: 'Show admin view',
icon: Icons.admin_panel_settings_outlined,
onTap: () => Navigator.of(context).pushNamed('/admin'),
),
SettingsElement(
text: 'Crash the app',
icon: Icons.fire_extinguisher,
Expand Down

0 comments on commit f8a772d

Please sign in to comment.