minor fixes in log page
and some more stuff regarding settings
This commit is contained in:
parent
9de0bd8c3c
commit
f686b8d3b0
|
@ -28,6 +28,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||||
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
final SharedPreferences prefs = await SharedPreferences.getInstance();
|
||||||
final apiKey = prefs.getString('apiKey');
|
final apiKey = prefs.getString('apiKey');
|
||||||
final shockerId = prefs.getString('shockerId');
|
final shockerId = prefs.getString('shockerId');
|
||||||
|
final logvalue = prefs.getDouble('logsSharedPreferenceKey') ?? 30;
|
||||||
|
|
||||||
if (apiKey == null || shockerId == null) {
|
if (apiKey == null || shockerId == null) {
|
||||||
// fuck you i dont handle missing stuff
|
// fuck you i dont handle missing stuff
|
||||||
|
@ -35,7 +36,7 @@ class _LogsPageState extends State<LogsPage> {
|
||||||
}
|
}
|
||||||
|
|
||||||
final url =
|
final url =
|
||||||
'https://api.shocklink.net/1/shockers/$shockerId/logs?offset=0&limit=30';
|
'https://api.shocklink.net/1/shockers/$shockerId/logs?offset=0&limit=40';
|
||||||
|
|
||||||
final response = await http.get(Uri.parse(url), headers: {
|
final response = await http.get(Uri.parse(url), headers: {
|
||||||
'accept': 'application/json',
|
'accept': 'application/json',
|
||||||
|
@ -92,12 +93,14 @@ class _LogsPageState extends State<LogsPage> {
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: SingleChildScrollView(
|
child: SingleChildScrollView(
|
||||||
child: DataTable(
|
child: DataTable(
|
||||||
|
columnSpacing: 10,
|
||||||
|
dataRowMaxHeight: 50,
|
||||||
columns: const [
|
columns: const [
|
||||||
DataColumn(label: Text('Name')),
|
DataColumn(label: Text('Name')),
|
||||||
DataColumn(label: Text('Intensity')),
|
DataColumn(label: Text('Intensity')),
|
||||||
DataColumn(label: Text('Duration (s)')),
|
DataColumn(label: Text('Duration')),
|
||||||
DataColumn(label: Text('Type')),
|
DataColumn(label: Text('Type')),
|
||||||
DataColumn(label: Text('Created At')),
|
DataColumn(label: Text('Time')),
|
||||||
],
|
],
|
||||||
rows: logs.map((log) {
|
rows: logs.map((log) {
|
||||||
final controlledBy =
|
final controlledBy =
|
||||||
|
|
|
@ -24,6 +24,9 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
|
|
||||||
bool showApiKey = false;
|
bool showApiKey = false;
|
||||||
bool showShockerId = false;
|
bool showShockerId = false;
|
||||||
|
double numberOfLogs = 30; // Default value for the number of logs
|
||||||
|
static const String logsSharedPreferenceKey =
|
||||||
|
'nlogs'; // Shared preference key
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
|
@ -38,6 +41,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
shockerIdController.text = prefs.getString('shockerId') ?? '';
|
shockerIdController.text = prefs.getString('shockerId') ?? '';
|
||||||
intensityLimitController.text = prefs.getString('intensityLimit') ?? '';
|
intensityLimitController.text = prefs.getString('intensityLimit') ?? '';
|
||||||
durationLimitController.text = prefs.getString('durationLimit') ?? '';
|
durationLimitController.text = prefs.getString('durationLimit') ?? '';
|
||||||
|
numberOfLogs = prefs.getDouble(logsSharedPreferenceKey) ?? 30;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -47,6 +51,9 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
prefs.setString('shockerId', shockerIdController.text);
|
prefs.setString('shockerId', shockerIdController.text);
|
||||||
await runChecks();
|
await runChecks();
|
||||||
|
|
||||||
|
// Save the selected number of logs to shared preferences
|
||||||
|
prefs.setDouble(logsSharedPreferenceKey, numberOfLogs);
|
||||||
|
|
||||||
Navigator.pop(context);
|
Navigator.pop(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,6 +176,24 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
obscureText: !showShockerId,
|
obscureText: !showShockerId,
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
|
Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text('Logs to be fetched: ${numberOfLogs.toInt()}'),
|
||||||
|
Slider(
|
||||||
|
value: numberOfLogs,
|
||||||
|
min: 0,
|
||||||
|
max: 100,
|
||||||
|
divisions: 100,
|
||||||
|
onChanged: (newValue) {
|
||||||
|
setState(() {
|
||||||
|
numberOfLogs = newValue;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const SizedBox(height: 16),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: saveSettings,
|
onPressed: saveSettings,
|
||||||
child: const Text('Save'),
|
child: const Text('Save'),
|
||||||
|
@ -183,7 +208,7 @@ class _SettingsPageState extends State<SettingsPage> {
|
||||||
return Text('Error: ${snapshot.error}');
|
return Text('Error: ${snapshot.error}');
|
||||||
} else {
|
} else {
|
||||||
return Text(
|
return Text(
|
||||||
'App Version: 0.3-rc0 - Build Date: Dec. 7, 2023\n'
|
'App Version: 0.3-rc0[hf] - Build Date: Dec. 11, 2023\n'
|
||||||
'(C) Mercury, 2023\n'
|
'(C) Mercury, 2023\n'
|
||||||
'Connected to api.shocklink.org, version ${snapshot.data}',
|
'Connected to api.shocklink.org, version ${snapshot.data}',
|
||||||
textAlign: TextAlign.left,
|
textAlign: TextAlign.left,
|
||||||
|
|
Loading…
Reference in a new issue