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
CARD_COLOR_LEFT=0xFF05112B
CARD_COLOR_RIGHT=0xFF085476
# Empty for default
CARD_COLOR_TEXT=Ğ1 Wallet Cop
CARD_COLOR_TEXT=Ğ1 Wallet
# Nodes space-separated
# 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> {
bool get isWarningViewed => state.warningViewed;
bool get isExpertMode => state.expertMode;
void introViewed() {
emit(state.copyWith(introViewed: true));
}
void warningViewed() {
emit(state.copyWith(warningViewed: true));
}
......@@ -26,4 +29,8 @@ class AppCubit extends HydratedCubit<AppState> {
Map<String, dynamic> toJson(AppState state) {
return state.toJson();
}
void setExpertMode(bool value) {
emit(state.copyWith(expertMode: value));
}
}
......@@ -10,6 +10,7 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
const AppState({
this.introViewed = false,
this.warningViewed = false,
this.expertMode = false,
});
factory AppState.fromJson(Map<String, dynamic> json) =>
......@@ -17,16 +18,17 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
final bool introViewed;
final bool warningViewed;
final bool expertMode;
AppState copyWith({
bool? introViewed,
bool? warningViewed,
DateTime? lastFetchTime,
bool? expertMode,
}) {
return AppState(
introViewed: introViewed ?? this.introViewed,
warningViewed: warningViewed ?? this.warningViewed,
);
introViewed: introViewed ?? this.introViewed,
warningViewed: warningViewed ?? this.warningViewed,
expertMode: expertMode ?? this.expertMode);
}
@override
......@@ -36,5 +38,5 @@ class AppState extends Equatable implements IsJsonSerializable<AppState> {
Map<String, dynamic> toJson() => _$AppStateToJson(this);
@override
List<Object?> get props => <Object>[introViewed, warningViewed];
List<Object?> get props => <Object>[introViewed, warningViewed, expertMode];
}
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 '../ui_helpers.dart';
import '../widgets/bottom_widget.dart';
......@@ -16,60 +19,75 @@ class FifthScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(
color: Theme.of(context).colorScheme.background,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
physics: const BouncingScrollPhysics(),
children: <Widget>[
const Header(text: 'bottom_nav_fifth'),
const TextDivider(text: 'key_tools_title'),
GridView.count(
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 2,
childAspectRatio: 2 / 1.15,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
shrinkWrap: true,
padding: EdgeInsets.zero,
children: <GridItem>[
GridItem(
title: 'export_key',
icon: Icons.download,
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return const ExportDialog();
},
);
}),
GridItem(
title: 'import_key',
icon: Icons.upload,
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return ImportDialog();
},
);
}),
GridItem(
title: 'copy_your_key',
icon: Icons.copy,
onTap: () => copyPublicKeyToClipboard(context),
)
]),
const TextDivider(text: 'technical_info_title'),
const NodeInfoCard(type: NodeType.duniter),
const NodeInfoCard(type: NodeType.cesiumPlus),
LinkCard(
title: 'code_card_title',
icon: Icons.code_rounded,
url: Uri.parse('https://git.duniter.org/vjrj/ginkgo')),
const BottomWidget()
]),
);
return BlocBuilder<AppCubit, AppState>(
builder: (BuildContext context, AppState state) => Material(
color: Theme.of(context).colorScheme.background,
child: ListView(
padding: const EdgeInsets.symmetric(horizontal: 16),
physics: const BouncingScrollPhysics(),
children: <Widget>[
const Header(text: 'bottom_nav_fifth'),
const TextDivider(text: 'key_tools_title'),
GridView.count(
physics: const NeverScrollableScrollPhysics(),
crossAxisCount: 2,
childAspectRatio: 2 / 1.15,
crossAxisSpacing: 8,
mainAxisSpacing: 8,
shrinkWrap: true,
padding: EdgeInsets.zero,
children: <GridItem>[
if (state.expertMode)
GridItem(
title: 'export_key',
icon: Icons.download,
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return const ExportDialog();
},
);
}),
if (state.expertMode)
GridItem(
title: 'import_key',
icon: Icons.upload,
onTap: () {
showDialog(
context: context,
builder: (BuildContext context) {
return ImportDialog();
},
);
}),
GridItem(
title: 'copy_your_key',
icon: Icons.copy,
onTap: () => copyPublicKeyToClipboard(context),
)
]),
if (state.expertMode)
const TextDivider(text: 'technical_info_title'),
if (state.expertMode)
const NodeInfoCard(type: NodeType.duniter),
if (state.expertMode)
const NodeInfoCard(type: NodeType.cesiumPlus),
if (state.expertMode)
LinkCard(
title: 'code_card_title',
icon: Icons.code_rounded,
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()
]),
));
}
}
......@@ -116,7 +116,9 @@ class _ExportDialogState extends State<ExportDialog> {
anchor.download = 'ginkgo-wallet.json';
anchor.click();
if (!mounted) return;
if (!mounted) {
return;
}
context.replaceSnackbar(
content: const Text(
"HURRA",
......
......@@ -93,7 +93,9 @@ class ImportDialog extends StatelessWidget {
try {
final String jsonString = reader.result as String;
logger(jsonString);
if (!kReleaseMode) {
logger(jsonString);
}
final dynamic jsonMap = jsonDecode(jsonString);
final SharedPreferences prefs = await SharedPreferences.getInstance();
completer.complete(jsonString);
......
......@@ -115,7 +115,9 @@ class _PayContactSearchPageState extends State<PayContactSearchPage> {
} else {
paymentCubit.selectKey(pay.publicKey);
}
if (!mounted) {
return;
}
Navigator.pop(context);
}
}),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment