Skip to content
Snippets Groups Projects
Commit f02c8e52 authored by vjrj's avatar vjrj
Browse files

Expert mode

parent f54cc247
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ SENTRY_DSN=https://306345cb87ee4e1cbbe9023fb4afc5fc@sentry.comunes.org/6 ...@@ -4,7 +4,7 @@ SENTRY_DSN=https://306345cb87ee4e1cbbe9023fb4afc5fc@sentry.comunes.org/6
CARD_COLOR_LEFT=0xFF05112B CARD_COLOR_LEFT=0xFF05112B
CARD_COLOR_RIGHT=0xFF085476 CARD_COLOR_RIGHT=0xFF085476
# Empty for default # Empty for default
CARD_COLOR_TEXT=Ğ1 Wallet Cop CARD_COLOR_TEXT=Ğ1 Wallet
# Nodes space-separated # Nodes space-separated
# The duniter nodes are only used at boot time, later it tries to calculate periodically the nodes # The duniter nodes are only used at boot time, later it tries to calculate periodically the nodes
......
...@@ -9,10 +9,13 @@ class AppCubit extends HydratedCubit<AppState> { ...@@ -9,10 +9,13 @@ class AppCubit extends HydratedCubit<AppState> {
bool get isWarningViewed => state.warningViewed; bool get isWarningViewed => state.warningViewed;
bool get isExpertMode => state.expertMode;
void introViewed() { void introViewed() {
emit(state.copyWith(introViewed: true)); emit(state.copyWith(introViewed: true));
} }
void warningViewed() { void warningViewed() {
emit(state.copyWith(warningViewed: true)); emit(state.copyWith(warningViewed: true));
} }
...@@ -26,4 +29,8 @@ class AppCubit extends HydratedCubit<AppState> { ...@@ -26,4 +29,8 @@ class AppCubit extends HydratedCubit<AppState> {
Map<String, dynamic> toJson(AppState state) { Map<String, dynamic> toJson(AppState state) {
return state.toJson(); return state.toJson();
} }
void setExpertMode(bool value) {
emit(state.copyWith(expertMode: value));
}
} }
...@@ -10,6 +10,7 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> { ...@@ -10,6 +10,7 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
const AppState({ const AppState({
this.introViewed = false, this.introViewed = false,
this.warningViewed = false, this.warningViewed = false,
this.expertMode = false,
}); });
factory AppState.fromJson(Map<String, dynamic> json) => factory AppState.fromJson(Map<String, dynamic> json) =>
...@@ -17,16 +18,17 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> { ...@@ -17,16 +18,17 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
final bool introViewed; final bool introViewed;
final bool warningViewed; final bool warningViewed;
final bool expertMode;
AppState copyWith({ AppState copyWith({
bool? introViewed, bool? introViewed,
bool? warningViewed, bool? warningViewed,
DateTime? lastFetchTime, bool? expertMode,
}) { }) {
return AppState( return AppState(
introViewed: introViewed ?? this.introViewed, introViewed: introViewed ?? this.introViewed,
warningViewed: warningViewed ?? this.warningViewed, warningViewed: warningViewed ?? this.warningViewed,
); expertMode: expertMode ?? this.expertMode);
} }
@override @override
...@@ -36,5 +38,5 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> { ...@@ -36,5 +38,5 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
Map<String, dynamic> toJson() => _$AppStateToJson(this); Map<String, dynamic> toJson() => _$AppStateToJson(this);
@override @override
List<Object?> get props => <Object>[introViewed, warningViewed]; List<Object?> get props => <Object>[introViewed, warningViewed, expertMode];
} }
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../data/models/app_cubit.dart';
import '../../data/models/app_state.dart';
import '../../data/models/node_manager.dart'; import '../../data/models/node_manager.dart';
import '../ui_helpers.dart'; import '../ui_helpers.dart';
import '../widgets/bottom_widget.dart'; import '../widgets/bottom_widget.dart';
...@@ -16,7 +19,8 @@ class FifthScreen extends StatelessWidget { ...@@ -16,7 +19,8 @@ class FifthScreen extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Material( return BlocBuilder<AppCubit, AppState>(
builder: (BuildContext context, AppState state) => Material(
color: Theme.of(context).colorScheme.background, color: Theme.of(context).colorScheme.background,
child: ListView( child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16), padding: const EdgeInsets.symmetric(horizontal: 16),
...@@ -33,6 +37,7 @@ class FifthScreen extends StatelessWidget { ...@@ -33,6 +37,7 @@ class FifthScreen extends StatelessWidget {
shrinkWrap: true, shrinkWrap: true,
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
children: <GridItem>[ children: <GridItem>[
if (state.expertMode)
GridItem( GridItem(
title: 'export_key', title: 'export_key',
icon: Icons.download, icon: Icons.download,
...@@ -44,6 +49,7 @@ class FifthScreen extends StatelessWidget { ...@@ -44,6 +49,7 @@ class FifthScreen extends StatelessWidget {
}, },
); );
}), }),
if (state.expertMode)
GridItem( GridItem(
title: 'import_key', title: 'import_key',
icon: Icons.upload, icon: Icons.upload,
...@@ -61,15 +67,27 @@ class FifthScreen extends StatelessWidget { ...@@ -61,15 +67,27 @@ class FifthScreen extends StatelessWidget {
onTap: () => copyPublicKeyToClipboard(context), onTap: () => copyPublicKeyToClipboard(context),
) )
]), ]),
if (state.expertMode)
const TextDivider(text: 'technical_info_title'), const TextDivider(text: 'technical_info_title'),
if (state.expertMode)
const NodeInfoCard(type: NodeType.duniter), const NodeInfoCard(type: NodeType.duniter),
if (state.expertMode)
const NodeInfoCard(type: NodeType.cesiumPlus), const NodeInfoCard(type: NodeType.cesiumPlus),
if (state.expertMode)
LinkCard( LinkCard(
title: 'code_card_title', title: 'code_card_title',
icon: Icons.code_rounded, icon: Icons.code_rounded,
url: Uri.parse('https://git.duniter.org/vjrj/ginkgo')), url:
Uri.parse('https://git.duniter.org/vjrj/ginkgo')),
const BottomWidget(),
SwitchListTile(
title: const Text('Expert mode'),
value: state.expertMode,
onChanged: (bool value) =>
context.read<AppCubit>().setExpertMode(value),
),
const BottomWidget() const BottomWidget()
]), ]),
); ));
} }
} }
...@@ -116,7 +116,9 @@ class _ExportDialogState extends State<ExportDialog> { ...@@ -116,7 +116,9 @@ class _ExportDialogState extends State<ExportDialog> {
anchor.download = 'ginkgo-wallet.json'; anchor.download = 'ginkgo-wallet.json';
anchor.click(); anchor.click();
if (!mounted) return; if (!mounted) {
return;
}
context.replaceSnackbar( context.replaceSnackbar(
content: const Text( content: const Text(
"HURRA", "HURRA",
......
...@@ -93,7 +93,9 @@ class ImportDialog extends StatelessWidget { ...@@ -93,7 +93,9 @@ class ImportDialog extends StatelessWidget {
try { try {
final String jsonString = reader.result as String; final String jsonString = reader.result as String;
if (!kReleaseMode) {
logger(jsonString); logger(jsonString);
}
final dynamic jsonMap = jsonDecode(jsonString); final dynamic jsonMap = jsonDecode(jsonString);
final SharedPreferences prefs = await SharedPreferences.getInstance(); final SharedPreferences prefs = await SharedPreferences.getInstance();
completer.complete(jsonString); completer.complete(jsonString);
......
...@@ -115,7 +115,9 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> { ...@@ -115,7 +115,9 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> {
} else { } else {
paymentCubit.selectKey(pay.publicKey); paymentCubit.selectKey(pay.publicKey);
} }
if (!mounted) {
return;
}
Navigator.pop(context); Navigator.pop(context);
} }
}), }),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment