Skip to content

Commit aa20a54

Browse files
committed
delete custom epicbox impl and some other minimal working changes
1 parent 03eb586 commit aa20a54

8 files changed

Lines changed: 388 additions & 303 deletions

File tree

lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ import 'db/hive/db.dart';
3333
import 'db/isar/main_db.dart';
3434
import 'db/special_migrations.dart';
3535
import 'db/sqlite/firo_cache.dart';
36+
import 'models/epicbox_server_model.dart';
3637
import 'models/exchange/change_now/exchange_transaction.dart';
3738
import 'models/exchange/change_now/exchange_transaction_status.dart';
3839
import 'models/exchange/response_objects/trade.dart';
3940
import 'models/models.dart';
4041
import 'models/node_model.dart';
4142
import 'models/notification_model.dart';
42-
import 'models/epicbox_server_model.dart';
4343
import 'models/trade_wallet_lookup.dart';
4444
import 'pages/campfire_migrate_view.dart';
4545
import 'pages/home_view/home_view.dart';

lib/pages/settings_views/wallet_settings_view/epicbox_settings/add_edit_epicbox_mobile_view.dart

Lines changed: 247 additions & 196 deletions
Large diffs are not rendered by default.

lib/pages/settings_views/wallet_settings_view/epicbox_settings/manage_epicbox_view.dart

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '../../../../notifications/show_flush_bar.dart';
77
import '../../../../providers/providers.dart';
88
import '../../../../themes/stack_colors.dart';
99
import '../../../../utilities/assets.dart';
10+
import '../../../../utilities/default_epicboxes.dart';
1011
import '../../../../utilities/test_epicbox_server_connection.dart';
1112
import '../../../../utilities/text_styles.dart';
1213
import '../../../../wallets/wallet/impl/epiccash_wallet.dart';
@@ -28,11 +29,11 @@ class ManageEpicboxView extends ConsumerStatefulWidget {
2829

2930
class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
3031
Future<void> _onConnect(String epicBoxId) async {
31-
final epicBox = ref
32-
.read(nodeServiceChangeNotifierProvider)
33-
.getEpicBoxById(id: epicBoxId);
34-
35-
if (epicBox == null) return;
32+
final epicBox =
33+
ref
34+
.read(nodeServiceChangeNotifierProvider)
35+
.getEpicBoxById(id: epicBoxId) ??
36+
DefaultEpicBoxes.all.firstWhere((e) => e.id == epicBoxId);
3637

3738
final data = EpicBoxFormData()
3839
..host = epicBox.host
@@ -79,6 +80,7 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
7980
arguments: (
8081
viewType: AddEditEpicboxMobileViewType.edit,
8182
epicBoxId: epicBoxId,
83+
routeOnSuccessOrDelete: ManageEpicboxView.routeName,
8284
),
8385
);
8486
}
@@ -89,6 +91,7 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
8991
arguments: (
9092
viewType: AddEditEpicboxMobileViewType.add,
9193
epicBoxId: null,
94+
routeOnSuccessOrDelete: ManageEpicboxView.routeName,
9295
),
9396
);
9497
}
@@ -104,9 +107,6 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
104107
),
105108
);
106109

107-
final defaultBoxes = epicBoxes.where((e) => e.isDefault).toList();
108-
final customBoxes = epicBoxes.where((e) => !e.isDefault).toList();
109-
110110
return Background(
111111
child: Scaffold(
112112
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
@@ -132,9 +132,9 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
132132
child: Center(
133133
child: Icon(
134134
Icons.add,
135-
color: Theme.of(context)
136-
.extension<StackColors>()!
137-
.topNavIconPrimary,
135+
color: Theme.of(
136+
context,
137+
).extension<StackColors>()!.topNavIconPrimary,
138138
size: 20,
139139
),
140140
),
@@ -151,7 +151,7 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
151151
child: Column(
152152
crossAxisAlignment: CrossAxisAlignment.start,
153153
children: [
154-
if (defaultBoxes.isNotEmpty) ...[
154+
...[
155155
Padding(
156156
padding: const EdgeInsets.symmetric(
157157
horizontal: 12,
@@ -166,20 +166,20 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
166166
),
167167
),
168168
),
169-
...defaultBoxes.map(
169+
...DefaultEpicBoxes.all.map(
170170
(epicBox) => Padding(
171171
padding: const EdgeInsets.symmetric(vertical: 4),
172172
child: EpicBoxCard(
173173
key: Key("${epicBox.id}_card_key"),
174174
epicBoxId: epicBox.id,
175175
onConnect: () => _onConnect(epicBox.id),
176-
onEdit: () => _onEdit(epicBox.id),
176+
onEdit: () {},
177177
testOnInit: primaryEpicBox?.id == epicBox.id,
178178
),
179179
),
180180
),
181181
],
182-
if (customBoxes.isNotEmpty) ...[
182+
if (epicBoxes.isNotEmpty) ...[
183183
Padding(
184184
padding: const EdgeInsets.symmetric(
185185
horizontal: 12,
@@ -194,7 +194,7 @@ class _ManageEpicboxViewState extends ConsumerState<ManageEpicboxView> {
194194
),
195195
),
196196
),
197-
...customBoxes.map(
197+
...epicBoxes.map(
198198
(epicBox) => Padding(
199199
padding: const EdgeInsets.symmetric(vertical: 4),
200200
child: EpicBoxCard(

lib/pages_desktop_specific/settings/settings_menu/epicbox_settings/add_edit_epicbox_view.dart

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import '../../../../utilities/constants.dart';
1212
import '../../../../utilities/test_epicbox_server_connection.dart';
1313
import '../../../../utilities/text_styles.dart';
1414
import '../../../../widgets/custom_buttons/app_bar_icon_button.dart';
15+
import '../../../../widgets/desktop/delete_button.dart';
1516
import '../../../../widgets/desktop/desktop_dialog.dart';
1617
import '../../../../widgets/desktop/primary_button.dart';
1718
import '../../../../widgets/desktop/secondary_button.dart';
@@ -27,7 +28,10 @@ class AddEditEpicBoxView extends ConsumerStatefulWidget {
2728
required this.viewType,
2829
this.epicBoxId,
2930
required this.onSave,
30-
});
31+
}) : assert(
32+
(viewType == .edit && epicBoxId != null) ||
33+
viewType == .add && epicBoxId == null,
34+
);
3135

3236
final AddEditEpicBoxViewType viewType;
3337
final String? epicBoxId;
@@ -198,27 +202,34 @@ class _AddEditEpicBoxViewState extends ConsumerState<AddEditEpicBoxView> {
198202
}
199203
}
200204

205+
late final bool canDelete;
206+
201207
@override
202208
void initState() {
203209
super.initState();
204210
_nameController = TextEditingController();
205211
_hostController = TextEditingController();
206212
_portController = TextEditingController();
207213

208-
if (widget.epicBoxId != null) {
209-
final epicBox = ref
210-
.read(nodeServiceChangeNotifierProvider)
211-
.getEpicBoxById(id: widget.epicBoxId!);
212-
if (epicBox != null) {
214+
switch (widget.viewType) {
215+
case .add:
216+
_portController.text = "443";
217+
port = 443;
218+
canDelete = false;
219+
break;
220+
221+
case .edit:
222+
final epicBox = ref
223+
.read(nodeServiceChangeNotifierProvider)
224+
.getEpicBoxById(id: widget.epicBoxId!)!;
225+
213226
_nameController.text = epicBox.name;
214227
_hostController.text = epicBox.host;
215228
_portController.text = (epicBox.port ?? 443).toString();
216229
_useSSL = epicBox.useSSL ?? true;
217230
port = epicBox.port ?? 443;
218-
}
219-
} else {
220-
_portController.text = "443";
221-
port = 443;
231+
canDelete = !epicBox.isDefault;
232+
break;
222233
}
223234
}
224235

@@ -416,7 +427,30 @@ class _AddEditEpicBoxViewState extends ConsumerState<AddEditEpicBoxView> {
416427
),
417428
],
418429
),
419-
const SizedBox(height: 78),
430+
const SizedBox(height: 22),
431+
if (canDelete)
432+
SizedBox(
433+
height: 56,
434+
child: Row(
435+
children: [
436+
Expanded(
437+
child: DeleteButton(
438+
label: "Delete node",
439+
desktopMed: true,
440+
onPressed: () {
441+
Navigator.of(context).pop();
442+
ref
443+
.read(nodeServiceChangeNotifierProvider)
444+
.deleteEpicBox(widget.epicBoxId!, true);
445+
},
446+
),
447+
),
448+
const SizedBox(width: 16),
449+
const Spacer(),
450+
],
451+
),
452+
),
453+
if (canDelete) const SizedBox(height: 45),
420454
Row(
421455
children: [
422456
Expanded(

lib/pages_desktop_specific/settings/settings_menu/epicbox_settings/desktop_manage_epicbox_dialog.dart

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import '../../../../notifications/show_flush_bar.dart';
77
import '../../../../providers/providers.dart';
88
import '../../../../themes/stack_colors.dart';
99
import '../../../../utilities/assets.dart';
10+
import '../../../../utilities/default_epicboxes.dart';
1011
import '../../../../utilities/test_epicbox_server_connection.dart';
1112
import '../../../../utilities/text_styles.dart';
1213
import '../../../../wallets/wallet/impl/epiccash_wallet.dart';
@@ -29,11 +30,11 @@ class DesktopManageEpicBoxDialog extends ConsumerStatefulWidget {
2930
class _DesktopManageEpicBoxDialogState
3031
extends ConsumerState<DesktopManageEpicBoxDialog> {
3132
Future<void> _onConnect(String epicBoxId) async {
32-
final epicBox = ref
33-
.read(nodeServiceChangeNotifierProvider)
34-
.getEpicBoxById(id: epicBoxId);
35-
36-
if (epicBox == null) return;
33+
final epicBox =
34+
ref
35+
.read(nodeServiceChangeNotifierProvider)
36+
.getEpicBoxById(id: epicBoxId) ??
37+
DefaultEpicBoxes.all.firstWhere((e) => e.id == epicBoxId);
3738

3839
final data = EpicBoxFormData()
3940
..host = epicBox.host
@@ -106,9 +107,6 @@ class _DesktopManageEpicBoxDialogState
106107
),
107108
);
108109

109-
final defaultBoxes = epicBoxes.where((e) => e.isDefault).toList();
110-
final customBoxes = epicBoxes.where((e) => !e.isDefault).toList();
111-
112110
return DesktopDialog(
113111
maxHeight: double.infinity,
114112
maxWidth: 580,
@@ -146,35 +144,33 @@ class _DesktopManageEpicBoxDialogState
146144
child: Column(
147145
crossAxisAlignment: CrossAxisAlignment.start,
148146
children: [
149-
if (defaultBoxes.isNotEmpty) ...[
150-
Padding(
151-
padding: const EdgeInsets.symmetric(
152-
horizontal: 12,
153-
vertical: 8,
154-
),
155-
child: Text(
156-
"Default servers",
157-
style: STextStyles.smallMed12(context).copyWith(
158-
color: Theme.of(
159-
context,
160-
).extension<StackColors>()!.textDark3,
161-
),
147+
Padding(
148+
padding: const EdgeInsets.symmetric(
149+
horizontal: 12,
150+
vertical: 8,
151+
),
152+
child: Text(
153+
"Default servers",
154+
style: STextStyles.smallMed12(context).copyWith(
155+
color: Theme.of(
156+
context,
157+
).extension<StackColors>()!.textDark3,
162158
),
163159
),
164-
...defaultBoxes.map(
165-
(epicBox) => Padding(
166-
padding: const EdgeInsets.symmetric(vertical: 4),
167-
child: EpicBoxCard(
168-
key: Key("${epicBox.id}_card_key"),
169-
epicBoxId: epicBox.id,
170-
onConnect: () => _onConnect(epicBox.id),
171-
onEdit: () => _onEdit(epicBox.id),
172-
testOnInit: primaryEpicBox?.id == epicBox.id,
173-
),
160+
),
161+
...DefaultEpicBoxes.all.map(
162+
(epicBox) => Padding(
163+
padding: const EdgeInsets.symmetric(vertical: 4),
164+
child: EpicBoxCard(
165+
key: Key("${epicBox.id}_card_key"),
166+
epicBoxId: epicBox.id,
167+
onConnect: () => _onConnect(epicBox.id),
168+
onEdit: () {}, // do nothing for defaults
169+
testOnInit: primaryEpicBox?.id == epicBox.id,
174170
),
175171
),
176-
],
177-
if (customBoxes.isNotEmpty) ...[
172+
),
173+
if (epicBoxes.isNotEmpty) ...[
178174
Padding(
179175
padding: const EdgeInsets.symmetric(
180176
horizontal: 12,
@@ -189,7 +185,7 @@ class _DesktopManageEpicBoxDialogState
189185
),
190186
),
191187
),
192-
...customBoxes.map(
188+
...epicBoxes.map(
193189
(epicBox) => Padding(
194190
padding: const EdgeInsets.symmetric(vertical: 4),
195191
child: EpicBoxCard(

lib/route_generator.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,7 @@ class RouteGenerator {
14441444
if (args is String) {
14451445
return getRoute(
14461446
shouldUseMaterialRoute: useMaterialPageRoute,
1447-
builder: (_) => ManageEpicboxView(
1448-
walletId: args,
1449-
),
1447+
builder: (_) => ManageEpicboxView(walletId: args),
14501448
settings: RouteSettings(name: settings.name),
14511449
);
14521450
}
@@ -1457,12 +1455,14 @@ class RouteGenerator {
14571455
is ({
14581456
AddEditEpicboxMobileViewType viewType,
14591457
String? epicBoxId,
1458+
String routeOnSuccessOrDelete,
14601459
})) {
14611460
return getRoute(
14621461
shouldUseMaterialRoute: useMaterialPageRoute,
14631462
builder: (_) => AddEditEpicboxMobileView(
14641463
viewType: args.viewType,
14651464
epicBoxId: args.epicBoxId,
1465+
routeOnSuccessOrDelete: args.routeOnSuccessOrDelete,
14661466
),
14671467
settings: RouteSettings(name: settings.name),
14681468
);

0 commit comments

Comments
 (0)