Files
moxxy/lib/ui/pages/settings/debugging.dart
Alexander "PapaTutuWawa 6a22a32724 ui: Fix the conversation's back button not working
When opening a new conversation from the NewConversationPage,
the navigation stack would be empty.
2022-08-06 20:44:37 +02:00

147 lines
5.8 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:flutter_settings_ui/flutter_settings_ui.dart';
import 'package:moxxyv2/shared/preferences.dart';
import 'package:moxxyv2/ui/bloc/preferences_bloc.dart';
import 'package:moxxyv2/ui/constants.dart';
import 'package:moxxyv2/ui/widgets/topbar.dart';
class DebuggingPage extends StatelessWidget {
DebuggingPage({ Key? key }) : _ipController = TextEditingController(), _passphraseController = TextEditingController(), _portController = TextEditingController(), super(key: key);
final TextEditingController _ipController;
final TextEditingController _portController;
final TextEditingController _passphraseController;
static MaterialPageRoute <dynamic>get route => MaterialPageRoute<dynamic>(
builder: (_) => DebuggingPage(),
settings: const RouteSettings(
name: debuggingRoute,
),
);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: BorderlessTopbar.simple('Debugging'),
body: BlocBuilder<PreferencesBloc, PreferencesState>(
builder: (context, state) => SettingsList(
darkBackgroundColor: const Color(0xff303030),
contentPadding: const EdgeInsets.all(16),
sections: [
SettingsSection(
title: 'General',
tiles: [
SettingsTile.switchTile(
title: 'Enable debugging',
onToggle: (value) => context.read<PreferencesBloc>().add(
PreferencesChangedEvent(
state.copyWith(debugEnabled: value),
),
),
switchValue: state.debugEnabled,
),
SettingsTile(
title: 'Encryption password',
subtitle: 'The logs may contain sensitive information so pick a strong passphrase',
subtitleMaxLines: 2,
onPressed: (context) {
showDialog<void>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) => AlertDialog(
title: const Text('Debug Passphrase'),
content: TextField(
minLines: 1,
obscureText: true,
controller: _passphraseController,
),
actions: [
TextButton(
child: const Text('Okay'),
onPressed: () {
context.read<PreferencesBloc>().add(
PreferencesChangedEvent(
state.copyWith(debugPassphrase: _passphraseController.text),
),
);
Navigator.of(context).pop();
},
)
],
),
);
},
),
SettingsTile(
title: 'Logging IP',
subtitle: 'The IP the logs should be sent to',
subtitleMaxLines: 2,
onPressed: (context) {
showDialog<void>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) => AlertDialog(
title: const Text('Logging IP'),
content: TextField(
minLines: 1,
controller: _ipController,
),
actions: [
TextButton(
child: const Text('Okay'),
onPressed: () {
context.read<PreferencesBloc>().add(
PreferencesChangedEvent(
state.copyWith(debugIp: _ipController.text),
),
);
Navigator.of(context).pop();
},
)
],
),
);
},
),
SettingsTile(
title: 'Logging Port',
subtitle: 'The Port the logs should be sent to',
subtitleMaxLines: 2,
onPressed: (context) {
showDialog<void>(
context: context,
barrierDismissible: true,
builder: (BuildContext context) => AlertDialog(
title: const Text('Logging Port'),
content: TextField(
minLines: 1,
controller: _portController,
keyboardType: TextInputType.number,
),
actions: [
TextButton(
child: const Text('Okay'),
onPressed: () {
context.read<PreferencesBloc>().add(
PreferencesChangedEvent(
state.copyWith(debugPort: int.parse(_portController.text)),
),
);
Navigator.of(context).pop();
},
)
],
),
);
},
)
],
)
],
),
),
);
}
}