Skip to content

Commit 1dc0021

Browse files
Merge pull request #84 from cypherstack/testing
Testing
2 parents 7478639 + 750f36c commit 1dc0021

File tree

10 files changed

+132
-22
lines changed

10 files changed

+132
-22
lines changed

lib/pages/address_book_views/subviews/add_address_book_entry_view.dart

Lines changed: 57 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import 'package:stackwallet/utilities/constants.dart';
1616
import 'package:stackwallet/utilities/text_styles.dart';
1717
import 'package:stackwallet/utilities/theme/stack_colors.dart';
1818
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
19+
import 'package:stackwallet/widgets/custom_buttons/blue_text_button.dart';
1920
import 'package:stackwallet/widgets/emoji_select_sheet.dart';
2021
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
2122
import 'package:stackwallet/widgets/stack_text_field.dart';
@@ -73,10 +74,23 @@ class _AddAddressBookEntryViewState
7374
}
7475

7576
List<NewContactAddressEntryForm> forms = [];
76-
int _formCount = 0;
77+
final Set<int> _formIds = {};
78+
79+
void _removeForm(int id) {
80+
forms.retainWhere((e) => e.id != id);
81+
_formIds.remove(id);
82+
ref.refresh(addressEntryDataProvider(id));
83+
setState(() {});
84+
}
7785

7886
void _addForm() {
79-
int id = ++_formCount;
87+
int id = 0;
88+
// ensure unique form id while allowing reuse of removed form ids
89+
while (_formIds.contains(id)) {
90+
id++;
91+
}
92+
_formIds.add(id);
93+
8094
forms.add(
8195
NewContactAddressEntryForm(
8296
key: Key("contactAddressEntryForm_$id"),
@@ -303,22 +317,34 @@ class _AddAddressBookEntryViewState
303317
},
304318
),
305319
),
306-
if (_formCount <= 1)
320+
if (forms.length <= 1)
307321
const SizedBox(
308322
height: 8,
309323
),
310-
if (_formCount <= 1) forms[0],
311-
if (_formCount > 1)
312-
for (int i = 0; i < _formCount; i++)
324+
if (forms.length <= 1) forms[0],
325+
if (forms.length > 1)
326+
for (int i = 0; i < forms.length; i++)
313327
Column(
314328
crossAxisAlignment: CrossAxisAlignment.start,
315329
children: [
316330
const SizedBox(
317331
height: 12,
318332
),
319-
Text(
320-
"Address ${i + 1}",
321-
style: STextStyles.smallMed12(context),
333+
Row(
334+
mainAxisAlignment:
335+
MainAxisAlignment.spaceBetween,
336+
children: [
337+
Text(
338+
"Address ${i + 1}",
339+
style: STextStyles.smallMed12(context),
340+
),
341+
BlueTextButton(
342+
onTap: () {
343+
_removeForm(forms[i].id);
344+
},
345+
text: "Remove",
346+
),
347+
],
322348
),
323349
const SizedBox(
324350
height: 8,
@@ -329,7 +355,7 @@ class _AddAddressBookEntryViewState
329355
const SizedBox(
330356
height: 16,
331357
),
332-
GestureDetector(
358+
BlueTextButton(
333359
onTap: () {
334360
_addForm();
335361
scrollController.animateTo(
@@ -338,11 +364,15 @@ class _AddAddressBookEntryViewState
338364
curve: Curves.easeInOut,
339365
);
340366
},
341-
child: Text(
342-
"+ Add another address",
343-
style: STextStyles.largeMedium14(context),
344-
),
367+
text: "+ Add another address",
345368
),
369+
// GestureDetector(
370+
//
371+
// child: Text(
372+
// "+ Add another address",
373+
// style: STextStyles.largeMedium14(context),
374+
// ),
375+
// ),
346376
const SizedBox(
347377
height: 16,
348378
),
@@ -411,10 +441,12 @@ class _AddAddressBookEntryViewState
411441
}
412442
List<ContactAddressEntry> entries =
413443
[];
414-
for (int i = 0; i < _formCount; i++) {
444+
for (int i = 0;
445+
i < forms.length;
446+
i++) {
415447
entries.add(ref
416448
.read(addressEntryDataProvider(
417-
i + 1))
449+
forms[i].id))
418450
.buildAddressEntry());
419451
}
420452
Contact contact = Contact(
@@ -438,7 +470,15 @@ class _AddAddressBookEntryViewState
438470
: null,
439471
child: Text(
440472
"Save",
441-
style: STextStyles.button(context),
473+
style: STextStyles.button(context).copyWith(
474+
color: shouldEnableSave
475+
? Theme.of(context)
476+
.extension<StackColors>()!
477+
.buttonTextPrimary
478+
: Theme.of(context)
479+
.extension<StackColors>()!
480+
.buttonTextPrimaryDisabled,
481+
),
442482
),
443483
);
444484
},

lib/pages/send_view/confirm_transaction_view.dart

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ class _ConfirmTransactionViewState
144144
final managerProvider = ref.watch(walletsChangeNotifierProvider
145145
.select((value) => value.getManagerProvider(walletId)));
146146
return Scaffold(
147+
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
147148
appBar: AppBar(
148149
backgroundColor: Theme.of(context).extension<StackColors>()!.background,
149150
leading: AppBarBackButton(
@@ -294,7 +295,12 @@ class _ConfirmTransactionViewState
294295
children: [
295296
Text(
296297
"Total amount",
297-
style: STextStyles.titleBold12(context),
298+
style:
299+
STextStyles.titleBold12(context).copyWith(
300+
color: Theme.of(context)
301+
.extension<StackColors>()!
302+
.textConfirmTotalAmount,
303+
),
298304
),
299305
Text(
300306
"${Format.satoshiAmountToPrettyString(
@@ -308,7 +314,12 @@ class _ConfirmTransactionViewState
308314
managerProvider
309315
.select((value) => value.coin),
310316
).ticker}",
311-
style: STextStyles.itemSubtitle12(context),
317+
style: STextStyles.itemSubtitle12(context)
318+
.copyWith(
319+
color: Theme.of(context)
320+
.extension<StackColors>()!
321+
.textConfirmTotalAmount,
322+
),
312323
textAlign: TextAlign.right,
313324
),
314325
],

lib/pages/send_view/send_view.dart

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,11 @@ class _SendViewState extends ConsumerState<SendView> {
10601060
height: 8,
10611061
),
10621062
TextField(
1063+
style: STextStyles.smallMed14(context).copyWith(
1064+
color: Theme.of(context)
1065+
.extension<StackColors>()!
1066+
.textDark,
1067+
),
10631068
key: const Key("amountInputFieldCryptoTextFieldKey"),
10641069
controller: cryptoAmountController,
10651070
focusNode: _cryptoFocus,
@@ -1106,6 +1111,11 @@ class _SendViewState extends ConsumerState<SendView> {
11061111
height: 8,
11071112
),
11081113
TextField(
1114+
style: STextStyles.smallMed14(context).copyWith(
1115+
color: Theme.of(context)
1116+
.extension<StackColors>()!
1117+
.textDark,
1118+
),
11091119
key: const Key("amountInputFieldFiatTextFieldKey"),
11101120
controller: baseAmountController,
11111121
focusNode: _baseFocus,

lib/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WalletNavigationBar extends StatelessWidget {
2727
return Container(
2828
height: height,
2929
decoration: BoxDecoration(
30-
color: Theme.of(context).extension<StackColors>()!.popupBG,
30+
color: Theme.of(context).extension<StackColors>()!.bottomNavBack,
3131
boxShadow: [
3232
Theme.of(context).extension<StackColors>()!.standardBoxShadow
3333
],

lib/services/coins/firo/firo_wallet.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ Future<dynamic> isolateCreateJoinSplitTransaction(
623623
"value": amount,
624624
"fees": Format.satoshisToAmount(fee).toDouble(),
625625
"fee": fee,
626+
"vSize": extTx.virtualSize(),
626627
"jmintValue": changeToMint,
627628
"publicCoin": "jmintData.publicCoin",
628629
"spendCoinIndexes": spendCoinIndexes,
@@ -1142,6 +1143,17 @@ class FiroWallet extends CoinServiceAPI {
11421143
throw Exception("Error Creating Transaction!");
11431144
}
11441145
} else {
1146+
final fee = txHexOrError["fee"] as int;
1147+
final vSize = txHexOrError["vSize"] as int;
1148+
1149+
Logging.instance.log("prepared fee: $fee", level: LogLevel.Info);
1150+
Logging.instance.log("prepared vSize: $vSize", level: LogLevel.Info);
1151+
1152+
// fee should never be less than vSize sanity check
1153+
if (fee < vSize) {
1154+
throw Exception(
1155+
"Error in fee calculation: Transaction fee cannot be less than vSize");
1156+
}
11451157
return txHexOrError as Map<String, dynamic>;
11461158
}
11471159
} catch (e, s) {

lib/services/wallets_service.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ class WalletsService extends ChangeNotifier {
294294
key: "${walletId}_mnemonicHasBeenVerified") as bool?;
295295

296296
if (isVerified == null) {
297+
Logging.instance.log(
298+
"isMnemonicVerified(walletId: $walletId) returned null which should never happen!",
299+
level: LogLevel.Error,
300+
);
297301
throw Exception(
298302
"isMnemonicVerified(walletId: $walletId) returned null which should never happen!");
299303
} else {
@@ -307,16 +311,28 @@ class WalletsService extends ChangeNotifier {
307311
key: "${walletId}_mnemonicHasBeenVerified") as bool?;
308312

309313
if (isVerified == null) {
314+
Logging.instance.log(
315+
"setMnemonicVerified(walletId: $walletId) tried running on non existent wallet!",
316+
level: LogLevel.Error,
317+
);
310318
throw Exception(
311319
"setMnemonicVerified(walletId: $walletId) tried running on non existent wallet!");
312320
} else if (isVerified) {
321+
Logging.instance.log(
322+
"setMnemonicVerified(walletId: $walletId) tried running on already verified wallet!",
323+
level: LogLevel.Error,
324+
);
313325
throw Exception(
314326
"setMnemonicVerified(walletId: $walletId) tried running on already verified wallet!");
315327
} else {
316328
await DB.instance.put<dynamic>(
317329
boxName: DB.boxNameAllWalletsData,
318330
key: "${walletId}_mnemonicHasBeenVerified",
319331
value: true);
332+
Logging.instance.log(
333+
"setMnemonicVerified(walletId: $walletId) successful",
334+
level: LogLevel.Error,
335+
);
320336
}
321337
}
322338

@@ -331,6 +347,11 @@ class WalletsService extends ChangeNotifier {
331347
return 3;
332348
}
333349

350+
Logging.instance.log(
351+
"deleteWallet called with name=$name and id=$walletId",
352+
level: LogLevel.Warning,
353+
);
354+
334355
final shell = names.remove(walletId);
335356

336357
if (shell == null) {

lib/utilities/theme/color_theme.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ abstract class StackColorTheme {
173173

174174
Color get loadingOverlayTextColor;
175175
Color get myStackContactIconBG;
176+
Color get textConfirmTotalAmount;
176177
}
177178

178179
class CoinThemeColor {

lib/utilities/theme/dark_colors.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class DarkColors extends StackColorTheme {
7070
@override
7171
Color get numpadBackDefault => const Color(0xFF4C86E9);
7272
@override
73-
Color get bottomNavBack => const Color(0xFFA2A2A2);
73+
Color get bottomNavBack => const Color(0xFF3E4148);
7474

7575
// button text/element
7676
@override
@@ -299,4 +299,6 @@ class DarkColors extends StackColorTheme {
299299
Color get loadingOverlayTextColor => const Color(0xFFF7F7F7);
300300
@override
301301
Color get myStackContactIconBG => const Color(0x88747778);
302+
@override
303+
Color get textConfirmTotalAmount => const Color(0xFF003921);
302304
}

lib/utilities/theme/light_colors.dart

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class LightColors extends StackColorTheme {
7070
@override
7171
Color get numpadBackDefault => const Color(0xFF232323);
7272
@override
73-
Color get bottomNavBack => const Color(0xFFA2A2A2);
73+
Color get bottomNavBack => const Color(0xFFFFFFFF);
7474

7575
// button text/element
7676
@override
@@ -299,4 +299,6 @@ class LightColors extends StackColorTheme {
299299
Color get loadingOverlayTextColor => const Color(0xFFF7F7F7);
300300
@override
301301
Color get myStackContactIconBG => textFieldDefaultBG;
302+
@override
303+
Color get textConfirmTotalAmount => const Color(0xFF232323);
302304
}

lib/utilities/theme/stack_colors.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class StackColors extends ThemeExtension<StackColors> {
168168
final Color warningBackground;
169169
final Color loadingOverlayTextColor;
170170
final Color myStackContactIconBG;
171+
final Color textConfirmTotalAmount;
171172

172173
StackColors({
173174
required this.themeType,
@@ -298,6 +299,7 @@ class StackColors extends ThemeExtension<StackColors> {
298299
required this.warningBackground,
299300
required this.loadingOverlayTextColor,
300301
required this.myStackContactIconBG,
302+
required this.textConfirmTotalAmount,
301303
});
302304

303305
factory StackColors.fromStackColorTheme(StackColorTheme colorTheme) {
@@ -432,6 +434,7 @@ class StackColors extends ThemeExtension<StackColors> {
432434
warningBackground: colorTheme.warningBackground,
433435
loadingOverlayTextColor: colorTheme.loadingOverlayTextColor,
434436
myStackContactIconBG: colorTheme.myStackContactIconBG,
437+
textConfirmTotalAmount: colorTheme.textConfirmTotalAmount,
435438
);
436439
}
437440

@@ -565,6 +568,7 @@ class StackColors extends ThemeExtension<StackColors> {
565568
Color? warningBackground,
566569
Color? loadingOverlayTextColor,
567570
Color? myStackContactIconBG,
571+
Color? textConfirmTotalAmount,
568572
}) {
569573
return StackColors(
570574
themeType: themeType ?? this.themeType,
@@ -730,6 +734,8 @@ class StackColors extends ThemeExtension<StackColors> {
730734
loadingOverlayTextColor:
731735
loadingOverlayTextColor ?? this.loadingOverlayTextColor,
732736
myStackContactIconBG: myStackContactIconBG ?? this.myStackContactIconBG,
737+
textConfirmTotalAmount:
738+
textConfirmTotalAmount ?? this.textConfirmTotalAmount,
733739
);
734740
}
735741

@@ -1377,6 +1383,11 @@ class StackColors extends ThemeExtension<StackColors> {
13771383
other.myStackContactIconBG,
13781384
t,
13791385
)!,
1386+
textConfirmTotalAmount: Color.lerp(
1387+
textConfirmTotalAmount,
1388+
other.textConfirmTotalAmount,
1389+
t,
1390+
)!,
13801391
);
13811392
}
13821393

0 commit comments

Comments
 (0)