Merge pull request #167 from cypherstack/ui-fixes

UI fixes
This commit is contained in:
julian-CStack 2022-10-20 11:33:18 -06:00 committed by GitHub
commit 31c6be4813
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 48 additions and 21 deletions

View file

@ -276,6 +276,12 @@ class ExchangeFormState extends ChangeNotifier {
void _onExchangeRateTypeChanged() {
print("_onExchangeRateTypeChanged");
updateRanges(shouldNotifyListeners: true).then(
(_) => updateEstimate(
shouldNotifyListeners: true,
reversed: reversed,
),
);
}
void _onExchangeTypeChanged() {

View file

@ -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();
@ -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
@ -272,6 +273,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
// if (!isDesktop)
RestoreFromDatePicker(
onTap: chooseDate,
controller: _dateController,
),
// if (isDesktop)

View file

@ -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();
@ -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(

View file

@ -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,
),
);
}
}
}

View file

@ -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,

View file

@ -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":
@ -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");

View file

@ -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 {