clean up unused code, imports, and formatting

This commit is contained in:
julian 2023-05-08 08:36:05 -06:00
parent c8655d56bc
commit 3f5cfcbfaf
5 changed files with 103 additions and 98 deletions

View file

@ -1,20 +1,19 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/widgets/choose_coin_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart'; import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/debug_view.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/advanced_views/manage_explorer_view.dart';
import 'package:stackwallet/pages/stack_privacy_calls.dart'; import 'package:stackwallet/pages/stack_privacy_calls.dart';
import 'package:stackwallet/providers/global/prefs_provider.dart'; import 'package:stackwallet/providers/global/prefs_provider.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/choose_coin_view.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart'; import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:tuple/tuple.dart'; import 'package:tuple/tuple.dart';
import 'manage_explorer_view.dart';
class AdvancedSettingsView extends StatelessWidget { class AdvancedSettingsView extends StatelessWidget {
const AdvancedSettingsView({ const AdvancedSettingsView({
Key? key, Key? key,
@ -240,7 +239,10 @@ class AdvancedSettingsView extends StatelessWidget {
), ),
onPressed: () { onPressed: () {
Navigator.of(context).pushNamed(ChooseCoinView.routeName, Navigator.of(context).pushNamed(ChooseCoinView.routeName,
arguments: const Tuple3<String, String, String>("Manage block explorers", "block explorer", ManageExplorerView.routeName)); arguments: const Tuple3<String, String, String>(
"Manage block explorers",
"block explorer",
ManageExplorerView.routeName));
}, },
child: Padding( child: Padding(
padding: const EdgeInsets.symmetric( padding: const EdgeInsets.symmetric(

View file

@ -1,13 +1,12 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/utilities/block_explorers.dart'; import 'package:stackwallet/utilities/block_explorers.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/widgets/background.dart'; import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart'; import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/widgets/rounded_white_container.dart';
import '../../../../widgets/rounded_white_container.dart';
class ManageExplorerView extends ConsumerStatefulWidget { class ManageExplorerView extends ConsumerStatefulWidget {
const ManageExplorerView({ const ManageExplorerView({
@ -24,23 +23,23 @@ class ManageExplorerView extends ConsumerStatefulWidget {
} }
class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> { class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> {
late TextEditingController textEditingController; late TextEditingController textEditingController;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
textEditingController = TextEditingController(text: getBlockExplorerTransactionUrlFor(coin: widget.coin, txid: "[TXID]").toString().replaceAll("%5BTXID%5D", "[TXID]")); textEditingController = TextEditingController(
text:
getBlockExplorerTransactionUrlFor(coin: widget.coin, txid: "[TXID]")
.toString()
.replaceAll("%5BTXID%5D", "[TXID]"));
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Background( return Background(
child: Scaffold( child: Scaffold(
backgroundColor: Theme.of(context).extension<StackColors>()! backgroundColor: Theme.of(context).extension<StackColors>()!.background,
.background,
appBar: AppBar( appBar: AppBar(
leading: AppBarBackButton( leading: AppBarBackButton(
onPressed: () { onPressed: () {
@ -56,7 +55,8 @@ class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> {
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Column( child: Column(
children: [ children: [
Expanded(child: Column( Expanded(
child: Column(
children: [ children: [
TextField( TextField(
controller: textEditingController, controller: textEditingController,
@ -64,12 +64,18 @@ class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> {
border: OutlineInputBorder(), border: OutlineInputBorder(),
), ),
), ),
const SizedBox(height: 8,), const SizedBox(
height: 8,
),
RoundedWhiteContainer( RoundedWhiteContainer(
child: Center( child: Center(
child: Text( child: Text(
"Edit your block explorer above. Keep in mind that every block explorer has a slightly different URL scheme.\n\n" "Edit your block explorer above. Keep in mind that "
"Paste in your block explorer of choice, then edit in [TXID] where the transaction ID should go, and Stack Wallet will auto fill the transaction ID in that place of URL.", "every block explorer has a slightly different URL "
"scheme.\n\nPaste in your block explorer of choice,"
" then edit in [TXID] where the transaction ID "
"should go, and Stack Wallet will auto fill the "
"transaction ID in that place of URL.",
style: STextStyles.itemSubtitle(context), style: STextStyles.itemSubtitle(context),
), ),
), ),
@ -78,7 +84,8 @@ class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> {
)), )),
Align( Align(
alignment: Alignment.bottomCenter, alignment: Alignment.bottomCenter,
child: ConstrainedBox(constraints: const BoxConstraints( child: ConstrainedBox(
constraints: const BoxConstraints(
minWidth: 480, minWidth: 480,
minHeight: 70, minHeight: 70,
), ),
@ -87,10 +94,12 @@ class _ManageExplorerViewState extends ConsumerState<ManageExplorerView> {
.extension<StackColors>()! .extension<StackColors>()!
.getPrimaryEnabledButtonStyle(context), .getPrimaryEnabledButtonStyle(context),
onPressed: () { onPressed: () {
textEditingController.text = textEditingController.text.trim(); textEditingController.text =
setBlockExplorerForCoin(coin: widget.coin, url: Uri.parse(textEditingController.text)).then((value) => textEditingController.text.trim();
Navigator.of(context).pop() setBlockExplorerForCoin(
); coin: widget.coin,
url: Uri.parse(textEditingController.text))
.then((value) => Navigator.of(context).pop());
}, },
child: Text( child: Text(
"Save", "Save",

View file

@ -1,11 +1,7 @@
import 'dart:ffi'; import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/isar/models/block_explorer.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart';
import '../db/hive/db.dart';
import '../db/isar/main_db.dart';
import '../models/isar/models/block_explorer.dart';
Uri getDefaultBlockExplorerUrlFor({ Uri getDefaultBlockExplorerUrlFor({
required Coin coin, required Coin coin,
required String txid, required String txid,
@ -48,18 +44,24 @@ Uri getDefaultBlockExplorerUrlFor({
} }
} }
Future<int> setBlockExplorerForCoin( /// returns internal Isar ID for the inserted object/record
{required Coin coin, required Uri url} Future<int> setBlockExplorerForCoin({
) async { required Coin coin,
await MainDB.instance.putTransactionBlockExplorer(TransactionBlockExplorer(ticker: coin.ticker, url: url.toString())); required Uri url,
return 0; }) async {
return await MainDB.instance.putTransactionBlockExplorer(
TransactionBlockExplorer(
ticker: coin.ticker,
url: url.toString(),
),
);
} }
Uri getBlockExplorerTransactionUrlFor({ Uri getBlockExplorerTransactionUrlFor({
required Coin coin, required Coin coin,
required String txid, required String txid,
}) { }) {
var url = MainDB.instance.getTransactionBlockExplorer(coin: coin)?.url.toString(); String? url = MainDB.instance.getTransactionBlockExplorer(coin: coin)?.url;
if (url == null) { if (url == null) {
return getDefaultBlockExplorerUrlFor(coin: coin, txid: txid); return getDefaultBlockExplorerUrlFor(coin: coin, txid: txid);
} else { } else {

View file

@ -7,8 +7,6 @@ import 'package:stackwallet/utilities/enums/sync_type_enum.dart';
import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart';
import 'package:uuid/uuid.dart'; import 'package:uuid/uuid.dart';
import 'enums/coin_enum.dart';
class Prefs extends ChangeNotifier { class Prefs extends ChangeNotifier {
Prefs._(); Prefs._();
static final Prefs _instance = Prefs._(); static final Prefs _instance = Prefs._();

View file

@ -1,7 +1,6 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart'; import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/pages/settings_views/global_settings_view/manage_nodes_views/coin_nodes_view.dart';
import 'package:stackwallet/providers/providers.dart'; import 'package:stackwallet/providers/providers.dart';
import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/constants.dart';
@ -65,7 +64,7 @@ class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
}, },
), ),
title: Text( title: Text(
widget.title ?? "Choose Coin", widget.title,
style: STextStyles.navBarTitle(context), style: STextStyles.navBarTitle(context),
), ),
), ),
@ -81,11 +80,6 @@ class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
children: [ children: [
...coins.map( ...coins.map(
(coin) { (coin) {
final count = ref
.watch(nodeServiceChangeNotifierProvider
.select((value) => value.getNodesFor(coin)))
.length;
return Padding( return Padding(
padding: const EdgeInsets.all(4), padding: const EdgeInsets.all(4),
child: RoundedWhiteContainer( child: RoundedWhiteContainer(
@ -121,7 +115,7 @@ class _ChooseCoinViewState extends ConsumerState<ChooseCoinView> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: [ children: [
Text( Text(
"${coin.prettyName} ${widget.coinAdditional ?? ""}", "${coin.prettyName} ${widget.coinAdditional}",
style: STextStyles.titleBold12(context), style: STextStyles.titleBold12(context),
), ),
], ],