mirror of
https://github.com/DefinedNet/mobile_nebula.git
synced 2025-09-07 19:46:06 +00:00
Compare commits
No commits in common. "0e4dd68b8457a736e76c8ce66b5159e79a6fe6b8" and "e5ca54f7f2119b0ea62499ab5cd38a980363ba5e" have entirely different histories.
0e4dd68b84
...
e5ca54f7f2
4 changed files with 16 additions and 65 deletions
|
@ -2,7 +2,7 @@ import 'dart:async';
|
||||||
|
|
||||||
import 'package:flutter/cupertino.dart' show CupertinoThemeData, DefaultCupertinoLocalizations;
|
import 'package:flutter/cupertino.dart' show CupertinoThemeData, DefaultCupertinoLocalizations;
|
||||||
import 'package:flutter/material.dart'
|
import 'package:flutter/material.dart'
|
||||||
show BottomSheetThemeData, Colors, DefaultMaterialLocalizations, ThemeData, ThemeMode;
|
show BottomSheetThemeData, Colors, DefaultMaterialLocalizations, ThemeData, ThemeMode, MaterialApp, Scaffold;
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter/widgets.dart';
|
import 'package:flutter/widgets.dart';
|
||||||
|
@ -15,22 +15,18 @@ import 'package:sentry_flutter/sentry_flutter.dart';
|
||||||
|
|
||||||
Future<void> main() async {
|
Future<void> main() async {
|
||||||
usePathUrlStrategy();
|
usePathUrlStrategy();
|
||||||
|
await SentryFlutter.init(
|
||||||
|
(options) {
|
||||||
|
options.dsn = 'https://96106df405ade3f013187dfc8e4200e7@o920269.ingest.us.sentry.io/4508132321001472';
|
||||||
|
// Capture all traces. May need to adjust if overwhelming
|
||||||
|
options.tracesSampleRate = 1.0;
|
||||||
|
// For each trace, capture all profiles
|
||||||
|
options.profilesSampleRate = 1.0;
|
||||||
|
},
|
||||||
|
appRunner: () => runApp(Main()),
|
||||||
|
);
|
||||||
|
|
||||||
var settings = Settings();
|
// or define SENTRY_DSN via Dart environment variable (--dart-define)
|
||||||
if (settings.trackErrors) {
|
|
||||||
await SentryFlutter.init(
|
|
||||||
(options) {
|
|
||||||
options.dsn = 'https://96106df405ade3f013187dfc8e4200e7@o920269.ingest.us.sentry.io/4508132321001472';
|
|
||||||
// Capture all traces. May need to adjust if overwhelming
|
|
||||||
options.tracesSampleRate = 1.0;
|
|
||||||
// For each trace, capture all profiles
|
|
||||||
options.profilesSampleRate = 1.0;
|
|
||||||
},
|
|
||||||
appRunner: () => runApp(Main()),
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
runApp(Main());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: EventChannel might be better than the stream controller we are using now
|
//TODO: EventChannel might be better than the stream controller we are using now
|
||||||
|
@ -56,24 +52,12 @@ class _AppState extends State<App> {
|
||||||
//TODO: wait until settings is ready?
|
//TODO: wait until settings is ready?
|
||||||
settings.onChange().listen((_) {
|
settings.onChange().listen((_) {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (settings.useSystemColors) {
|
if (!settings.useSystemColors) {
|
||||||
brightness = SchedulerBinding.instance.platformDispatcher.platformBrightness;
|
|
||||||
} else {
|
|
||||||
brightness = settings.darkMode ? Brightness.dark : Brightness.light;
|
brightness = settings.darkMode ? Brightness.dark : Brightness.light;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// Listen to changes to the system brightness mode, update accordingly
|
|
||||||
final dispatcher = SchedulerBinding.instance.platformDispatcher;
|
|
||||||
dispatcher.onPlatformBrightnessChanged = () {
|
|
||||||
if (settings.useSystemColors) {
|
|
||||||
setState(() {
|
|
||||||
brightness = dispatcher.platformBrightness;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,27 +85,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||||
)),
|
)),
|
||||||
));
|
));
|
||||||
|
|
||||||
items.add(ConfigSection(children: [
|
|
||||||
ConfigItem(
|
|
||||||
label: Text('Report errors automatically'),
|
|
||||||
labelWidth: 250,
|
|
||||||
content: Align(
|
|
||||||
alignment: Alignment.centerRight,
|
|
||||||
child: Switch.adaptive(
|
|
||||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
||||||
value: settings.trackErrors,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
settings.trackErrors = value;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
))),
|
|
||||||
]));
|
|
||||||
|
|
||||||
items.add(ConfigSection(children: [
|
items.add(ConfigSection(children: [
|
||||||
ConfigPageItem(
|
ConfigPageItem(
|
||||||
label: Text('Enroll with Managed Nebula'),
|
label: Text('Enroll with Managed Nebula'),
|
||||||
labelWidth: 250,
|
labelWidth: 200,
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
Utils.openPage(context, (context) => EnrollmentScreen(stream: widget.stream, allowCodeEntry: true)))
|
Utils.openPage(context, (context) => EnrollmentScreen(stream: widget.stream, allowCodeEntry: true)))
|
||||||
]));
|
]));
|
||||||
|
|
|
@ -3,10 +3,6 @@ import 'dart:convert';
|
||||||
import 'package:flutter/cupertino.dart';
|
import 'package:flutter/cupertino.dart';
|
||||||
import 'package:flutter/scheduler.dart';
|
import 'package:flutter/scheduler.dart';
|
||||||
import 'package:mobile_nebula/services/storage.dart';
|
import 'package:mobile_nebula/services/storage.dart';
|
||||||
import 'package:sentry_flutter/sentry_flutter.dart';
|
|
||||||
|
|
||||||
bool DEFAULT_LOG_WRAP = false;
|
|
||||||
bool DEFAULT_TRACK_ERRORS = true;
|
|
||||||
|
|
||||||
class Settings {
|
class Settings {
|
||||||
final _storage = Storage();
|
final _storage = Storage();
|
||||||
|
@ -34,26 +30,13 @@ class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get logWrap {
|
bool get logWrap {
|
||||||
return _getBool('logWrap', DEFAULT_LOG_WRAP);
|
return _getBool('logWrap', false);
|
||||||
}
|
}
|
||||||
|
|
||||||
set logWrap(bool enabled) {
|
set logWrap(bool enabled) {
|
||||||
_set('logWrap', enabled);
|
_set('logWrap', enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool get trackErrors {
|
|
||||||
return _getBool('trackErrors', DEFAULT_TRACK_ERRORS);
|
|
||||||
}
|
|
||||||
|
|
||||||
set trackErrors(bool enabled) {
|
|
||||||
_set('trackErrors', enabled);
|
|
||||||
|
|
||||||
// Side-effect: Disable Sentry immediately
|
|
||||||
if (!enabled) {
|
|
||||||
Sentry.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _getString(String key, String defaultValue) {
|
String _getString(String key, String defaultValue) {
|
||||||
final val = _settings[key];
|
final val = _settings[key];
|
||||||
if (val is String) {
|
if (val is String) {
|
||||||
|
|
|
@ -42,6 +42,7 @@ class Storage {
|
||||||
// Read the file
|
// Read the file
|
||||||
return await file.readAsString();
|
return await file.readAsString();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
// If encountering an error, return 0
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue