Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/models/exchange/exchange_form_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,12 @@ class ExchangeFormState extends ChangeNotifier {

void _onExchangeRateTypeChanged() {
print("_onExchangeRateTypeChanged");
updateRanges(shouldNotifyListeners: true).then(
(_) => updateEstimate(
shouldNotifyListeners: true,
reversed: reversed,
),
);
}

void _onExchangeTypeChanged() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {

Future<void> chooseDate() async {
final height = MediaQuery.of(context).size.height;
final fetchedColor =
Theme.of(context).extension<StackColors>()!.accentColorDark;
// check and hide keyboard
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
Expand All @@ -155,8 +157,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
initialDate: DateTime.now(),
height: height * 0.5,
theme: ThemeData(
primarySwatch: Util.createMaterialColor(
Theme.of(context).extension<StackColors>()!.accentColorDark),
primarySwatch: Util.createMaterialColor(fetchedColor),
),
//TODO pick a better initial date
// 2007 chosen as that is just before bitcoin launched
Expand Down Expand Up @@ -272,6 +273,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
// if (!isDesktop)
RestoreFromDatePicker(
onTap: chooseDate,
controller: _dateController,
),

// if (isDesktop)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';

class RestoreFromDatePicker extends StatefulWidget {
const RestoreFromDatePicker({Key? key, required this.onTap})
: super(key: key);
const RestoreFromDatePicker({
Key? key,
required this.onTap,
required this.controller,
}) : super(key: key);

final VoidCallback onTap;
final TextEditingController controller;

@override
State<RestoreFromDatePicker> createState() => _RestoreFromDatePickerState();
Expand All @@ -21,17 +25,11 @@ class _RestoreFromDatePickerState extends State<RestoreFromDatePicker> {
@override
void initState() {
onTap = widget.onTap;
_dateController = TextEditingController();
_dateController = widget.controller;

super.initState();
}

@override
void dispose() {
_dateController.dispose();
super.dispose();
}

@override
Widget build(BuildContext context) {
return Container(
Expand Down
13 changes: 13 additions & 0 deletions lib/services/node_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,19 @@ class NodeService extends ChangeNotifier {
key: savedNode.id,
value: defaultNode.copyWith(enabled: savedNode.enabled));
}

// check if a default node is the primary node for the crypto currency
// and update it if needed
final coin = coinFromPrettyName(defaultNode.coinName);
final primaryNode = getPrimaryNodeFor(coin: coin);
if (primaryNode != null && primaryNode.id == defaultNode.id) {
await setPrimaryNodeFor(
coin: coin,
node: defaultNode.copyWith(
enabled: primaryNode.enabled,
),
);
}
}
}

Expand Down
12 changes: 4 additions & 8 deletions lib/utilities/default_nodes.dart
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,24 @@ abstract class DefaultNodes {
isDown: false,
);

// TODO: eventually enable ssl and set scheme to https
// currently get certificate failure
static NodeModel get monero => NodeModel(
host: "http://monero.stackwallet.com",
host: "https://monero.stackwallet.com",
port: 18081,
name: defaultName,
id: _nodeId(Coin.monero),
useSSL: false,
useSSL: true,
enabled: true,
coinName: Coin.monero.name,
isFailover: true,
isDown: false,
);

// TODO: eventually enable ssl and set scheme to https
// currently get certificate failure
static NodeModel get wownero => NodeModel(
host: "http://eu-west-2.wow.xmr.pm",
host: "https://wownero.stackwallet.com",
port: 34568,
name: defaultName,
id: _nodeId(Coin.wownero),
useSSL: false,
useSSL: true,
enabled: true,
coinName: Coin.wownero.name,
isFailover: true,
Expand Down
12 changes: 12 additions & 0 deletions lib/utilities/enums/coin_enum.dart
Original file line number Diff line number Diff line change
Expand Up @@ -181,25 +181,32 @@ Coin coinFromPrettyName(String name) {
case "Bitcoin":
case "bitcoin":
return Coin.bitcoin;

case "Bitcoincash":
case "bitcoincash":
case "Bitcoin Cash":
return Coin.bitcoincash;

case "Dogecoin":
case "dogecoin":
return Coin.dogecoin;

case "Epic Cash":
case "epicCash":
return Coin.epicCash;

case "Firo":
case "firo":
return Coin.firo;

case "Monero":
case "monero":
return Coin.monero;

case "Namecoin":
case "namecoin":
return Coin.namecoin;

case "Bitcoin Testnet":
case "tBitcoin":
case "bitcoinTestNet":
Expand All @@ -208,19 +215,24 @@ Coin coinFromPrettyName(String name) {
case "Bitcoincash Testnet":
case "tBitcoin Cash":
case "Bitcoin Cash Testnet":
case "bitcoincashTestnet":
return Coin.bitcoincashTestnet;

case "Firo Testnet":
case "tFiro":
case "firoTestNet":
return Coin.firoTestNet;

case "Dogecoin Testnet":
case "tDogecoin":
case "dogecoinTestNet":
return Coin.dogecoinTestNet;

case "Wownero":
case "tWownero":
case "wownero":
return Coin.wownero;

default:
throw ArgumentError.value(
name, "name", "No Coin enum value with that prettyName");
Expand Down
4 changes: 2 additions & 2 deletions lib/widgets/node_options_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,10 @@ class NodeOptionsSheet extends ConsumerWidget {
style: status == "Connected"
? Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context)
.getPrimaryDisabledButtonColor(context)
: Theme.of(context)
.extension<StackColors>()!
.getPrimaryDisabledButtonColor(context),
.getPrimaryEnabledButtonColor(context),
onPressed: status == "Connected"
? null
: () async {
Expand Down