Add logWrap to global settings
`logWrap` is a configuration that allows for users to decide if when viewing logs the lines should extend off screen allowing for scroll behavior or if they should wrap at screen edge. We also considered allowing users to toggle this setting at the Site level but decided that since users would likely want this setting to apply to all sites, we hoisted the configuration. Advances #3
This commit is contained in:
parent
dd1bc9e3f9
commit
e844e2c195
|
@ -109,4 +109,4 @@ SPEC CHECKSUMS:
|
|||
|
||||
PODFILE CHECKSUM: e8d4fb1ed5b0713de2623a28dfae2585e15c0d00
|
||||
|
||||
COCOAPODS: 1.9.0
|
||||
COCOAPODS: 1.10.0
|
||||
|
|
|
@ -66,7 +66,27 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
|||
|
||||
List<Widget> items = [];
|
||||
items.add(ConfigSection(children: colorSection));
|
||||
items.add(ConfigSection(children: [ConfigPageItem(label: Text('About'), onPressed: () => Utils.openPage(context, (context) => AboutScreen()),)]));
|
||||
items.add(ConfigItem(
|
||||
label: Text('Wrap log output'),
|
||||
labelWidth: 200,
|
||||
content: Align(
|
||||
alignment: Alignment.centerRight,
|
||||
child: Switch.adaptive(
|
||||
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
||||
value: settings.logWrap,
|
||||
onChanged: (value) {
|
||||
setState(() {
|
||||
settings.logWrap = value;
|
||||
});
|
||||
},
|
||||
)),
|
||||
));
|
||||
items.add(ConfigSection(children: [
|
||||
ConfigPageItem(
|
||||
label: Text('About'),
|
||||
onPressed: () => Utils.openPage(context, (context) => AboutScreen()),
|
||||
)
|
||||
]));
|
||||
|
||||
return SimplePage(
|
||||
title: 'Settings',
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'package:flutter_platform_widgets/flutter_platform_widgets.dart';
|
|||
import 'package:mobile_nebula/components/SimplePage.dart';
|
||||
import 'package:mobile_nebula/components/SpecialSelectableText.dart';
|
||||
import 'package:mobile_nebula/models/Site.dart';
|
||||
import 'package:mobile_nebula/services/settings.dart';
|
||||
import 'package:mobile_nebula/services/share.dart';
|
||||
import 'package:mobile_nebula/services/utils.dart';
|
||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
||||
|
@ -25,6 +26,7 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
ScrollController controller = ScrollController();
|
||||
RefreshController refreshController = RefreshController(initialRefresh: false);
|
||||
|
||||
var settings = Settings();
|
||||
@override
|
||||
void initState() {
|
||||
loadLogs();
|
||||
|
@ -52,10 +54,7 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
refreshController.loadComplete();
|
||||
},
|
||||
refreshController: refreshController,
|
||||
child: Container(
|
||||
padding: EdgeInsets.all(5),
|
||||
constraints: BoxConstraints(minWidth: MediaQuery.of(context).size.width),
|
||||
child: SpecialSelectableText(logs.trim(), style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14))),
|
||||
child: Container(padding: EdgeInsets.all(5), constraints: logBoxConstraints(context), child: SpecialSelectableText(logs.trim(), style: TextStyle(fontFamily: 'RobotoMono', fontSize: 14))),
|
||||
bottomBar: _buildBottomBar(),
|
||||
);
|
||||
}
|
||||
|
@ -95,8 +94,7 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
padding: padding,
|
||||
icon: Icon(context.platformIcons.downArrow, size: 30),
|
||||
onPressed: () async {
|
||||
controller.animateTo(controller.position.maxScrollExtent,
|
||||
duration: const Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
|
||||
controller.animateTo(controller.position.maxScrollExtent, duration: const Duration(milliseconds: 500), curve: Curves.linearToEaseOut);
|
||||
},
|
||||
)),
|
||||
]));
|
||||
|
@ -120,4 +118,12 @@ class _SiteLogsScreenState extends State<SiteLogsScreen> {
|
|||
await file.writeAsBytes([]);
|
||||
await loadLogs();
|
||||
}
|
||||
|
||||
logBoxConstraints(BuildContext context) {
|
||||
if (settings.logWrap) {
|
||||
return BoxConstraints(maxWidth: MediaQuery.of(context).size.width);
|
||||
} else {
|
||||
return BoxConstraints(minWidth: MediaQuery.of(context).size.width);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ class Settings {
|
|||
_set('darkMode', enabled);
|
||||
}
|
||||
|
||||
bool get logWrap {
|
||||
return _getBool('logWrap', false);
|
||||
}
|
||||
|
||||
set logWrap(bool enabled) {
|
||||
_set('logWrap', enabled);
|
||||
}
|
||||
|
||||
String _getString(String key, String defaultValue) {
|
||||
final val = _settings[key];
|
||||
if (val is String) {
|
||||
|
|
Loading…
Reference in New Issue