WIP: ADD ECR-20

This commit is contained in:
likho 2023-01-16 15:19:32 +02:00
parent dd8319ee11
commit b5a1983734
10 changed files with 393 additions and 0 deletions

View file

@ -0,0 +1,10 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_7035_24064)">
<path d="M0 10C0 4.47656 4.47656 0 10 0C15.5234 0 20 4.47656 20 10C20 15.5234 15.5234 20 10 20C4.47656 20 0 15.5234 0 10ZM10 14.375C10.5195 14.375 10.9375 13.957 10.9375 13.4375V10.9375H13.4375C13.957 10.9375 14.375 10.5195 14.375 10C14.375 9.48047 13.957 9.0625 13.4375 9.0625H10.9375V6.5625C10.9375 6.04297 10.5195 5.625 10 5.625C9.48047 5.625 9.0625 6.04297 9.0625 6.5625V9.0625H6.5625C6.04297 9.0625 5.625 9.48047 5.625 10C5.625 10.5195 6.04297 10.9375 6.5625 10.9375H9.0625V13.4375C9.0625 13.957 9.48047 14.375 10 14.375Z" fill="#232323"/>
</g>
<defs>
<clipPath id="clip0_7035_24064">
<rect width="20" height="20" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 796 B

11
assets/svg/tokens.svg Normal file
View file

@ -0,0 +1,11 @@
<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_6872_133577)">
<path d="M18 11.25C18 12.0938 17.3297 12.8719 16.2 13.5C14.5594 14.4094 11.9437 15 9 15C6.20625 15 3.70594 14.4703 2.055 13.6359C1.96734 13.5891 1.88203 13.5047 1.79953 13.5C0.669375 12.8719 0 12.0938 0 11.25C0 9.17812 4.02937 7.5 9 7.5C13.9688 7.5 18 9.17812 18 11.25ZM9 16.5C11.6344 16.5 14.0906 16.0594 15.9422 15.2859C16.7063 14.9672 17.4141 14.5734 18 14.0906V15.75C18 16.5938 17.3297 17.3719 16.2 18C16.1156 18.0047 16.0313 18.0891 15.9469 18.1359C14.2922 18.9703 11.7937 19.5 9 19.5C6.05625 19.5 3.44109 18.9094 1.79953 18C0.669375 17.3719 0 16.5938 0 15.75V14.0906C0.583594 14.5734 1.29469 14.9672 2.05922 15.2859C3.91125 16.0594 6.36562 16.5 9 16.5ZM18 18.5906V20.25C18 22.3219 13.9688 24 9 24C4.02937 24 0 22.3219 0 20.25V18.5906C0.583594 19.0734 1.29469 19.4672 2.05922 19.7859C3.91125 20.5594 6.36562 21 9 21C11.6344 21 14.0906 20.5594 15.9422 19.7859C16.7063 19.4672 17.4141 19.0734 18 18.5906Z" fill="black"/>
<path opacity="0.4" d="M24 3.75C24 4.59422 23.3297 5.37188 22.2 6C20.8359 6.75469 18.8062 7.28906 16.4672 7.44844C16.2984 7.36875 16.1203 7.28906 15.9422 7.21406C14.0906 6.44062 11.6344 6 9 6C8.61094 6 8.23125 6.00938 7.85156 6.02813C7.83281 6.01875 7.81875 6.00938 7.8 6C6.67031 5.37188 6 4.59422 6 3.75C6 1.67906 9.98906 0 15 0C19.9688 0 24 1.67906 24 3.75ZM19.5 13.0359C20.3484 12.8016 21.2109 12.5906 21.9422 12.2859C22.7063 11.9672 23.4141 11.5734 24 11.0906V12.75C24 14.1375 22.1906 15.3516 19.5 15.9984V13.0359ZM19.5 11.25C19.5 10.2234 19.0031 9.37969 18.3703 8.74688C19.6969 8.54063 20.9109 8.2125 21.9422 7.78594C22.7063 7.46719 23.4141 7.07344 24 6.59063V8.25C24 9.09375 23.3297 9.87188 22.2 10.5C22.1156 10.5047 22.0313 10.5891 21.9469 10.6359C21.2625 10.9781 20.4328 11.2734 19.5 11.4984V11.25Z" fill="black"/>
</g>
<defs>
<clipPath id="clip0_6872_133577">
<rect width="24" height="24" fill="white"/>
</clipPath>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 2 KiB

View file

@ -0,0 +1,16 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
class AllTokensView extends ConsumerStatefulWidget {
const AllTokensView({
Key? key,
}) : super(key: key);
static const String routeName = "/allTokens";
@override
ConsumerState<ConsumerStatefulWidget> createState() {
// TODO: implement createState
throw UnimplementedError();
}
}

View file

@ -0,0 +1,265 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/svg.dart';
import 'package:stackwallet/utilities/theme/stack_colors.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
import 'package:stackwallet/pages/token_view/all_tokens_view.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/icon_widgets/x_icon.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:stackwallet/widgets/textfield_icon_button.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/no_transactions_found.dart';
class MyTokensView extends ConsumerStatefulWidget {
const MyTokensView({
Key? key,
required this.walletId,
}) : super(key: key);
static const String routeName = "/myTokens";
final String walletId;
@override
ConsumerState<MyTokensView> createState() => _TokenDetailsViewState();
}
class _TokenDetailsViewState extends ConsumerState<MyTokensView> {
late final String walletId;
late final TextEditingController _searchController;
final searchFieldFocusNode = FocusNode();
@override
void initState() {
walletId = widget.walletId;
_searchController = TextEditingController();
super.initState();
}
@override
void dispose() {
_searchController.dispose();
searchFieldFocusNode.dispose();
super.dispose();
}
String _searchString = "";
@override
Widget build(BuildContext context) {
final isDesktop = Util.isDesktop;
return MasterScaffold(
background: Theme.of(context).extension<StackColors>()!.background,
isDesktop: isDesktop,
appBar: isDesktop
? DesktopAppBar(
isCompactHeight: true,
background: Theme.of(context).extension<StackColors>()!.popupBG,
leading: Row(
children: [
const SizedBox(
width: 32,
),
AppBarIconButton(
size: 32,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
shadows: const [],
icon: SvgPicture.asset(
Assets.svg.arrowLeft,
width: 18,
height: 18,
color: Theme.of(context)
.extension<StackColors>()!
.topNavIconPrimary,
),
onPressed: Navigator.of(context).pop,
),
const SizedBox(
width: 12,
),
Text(
"My ETH Wallet Tokens",
style: STextStyles.desktopH3(context),
),
],
),
)
: AppBar(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
leading: AppBarBackButton(
onPressed: () async {
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
await Future<void>.delayed(
const Duration(milliseconds: 75));
}
if (mounted) {
Navigator.of(context).pop();
}
},
),
title: Text(
"My ETH Wallet Tokens",
style: STextStyles.navBarTitle(context),
),
actions: [
Padding(
padding: const EdgeInsets.only(
top: 10,
bottom: 10,
right: 20,
),
child: AspectRatio(
aspectRatio: 1,
child: AppBarIconButton(
key: const Key("transactionSearchFilterViewButton"),
size: 36,
shadows: const [],
color: Theme.of(context)
.extension<StackColors>()!
.background,
icon: SvgPicture.asset(
Assets.svg.circlePlusDark,
color: Theme.of(context)
.extension<StackColors>()!
.accentColorDark,
width: 20,
height: 20,
),
onPressed: () {
Navigator.of(context).pushNamed(
AllTokensView.routeName,
);
},
),
),
),
],
),
body: Padding(
padding: EdgeInsets.only(
left: isDesktop ? 20 : 12,
top: isDesktop ? 20 : 12,
right: isDesktop ? 20 : 12,
),
child: Column(
children: [
Padding(
padding: const EdgeInsets.all(4),
child: Row(
children: [
ConditionalParent(
condition: isDesktop,
builder: (child) => SizedBox(
width: 570,
child: child,
),
child: ConditionalParent(
condition: !isDesktop,
builder: (child) => Expanded(
child: child,
),
child: ClipRRect(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
child: TextField(
autocorrect: !isDesktop,
enableSuggestions: !isDesktop,
controller: _searchController,
focusNode: searchFieldFocusNode,
onChanged: (value) {
setState(() {
_searchString = value;
});
},
style: isDesktop
? STextStyles.desktopTextExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveText,
height: 1.8,
)
: STextStyles.field(context),
decoration: standardInputDecoration(
"Search...",
searchFieldFocusNode,
context,
desktopMed: isDesktop,
).copyWith(
prefixIcon: Padding(
padding: EdgeInsets.symmetric(
horizontal: isDesktop ? 12 : 10,
vertical: isDesktop ? 18 : 16,
),
child: SvgPicture.asset(
Assets.svg.search,
width: isDesktop ? 20 : 16,
height: isDesktop ? 20 : 16,
),
),
suffixIcon: _searchController.text.isNotEmpty
? Padding(
padding: const EdgeInsets.only(right: 0),
child: UnconstrainedBox(
child: Row(
children: [
TextFieldIconButton(
child: const XIcon(),
onTap: () async {
setState(() {
_searchController.text = "";
_searchString = "";
});
},
),
],
),
),
)
: null,
),
),
),
),
),
if (isDesktop)
const SizedBox(
width: 20,
),
// const NoTransActionsFound(),
],
),
),
if (isDesktop)
const SizedBox(
height: 8,
),
const SizedBox(
height: 8,
),
],
),
),
);
}
}

View file

@ -0,0 +1,25 @@
import 'package:flutter/cupertino.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
class NoTokensFound extends StatelessWidget {
const NoTokensFound({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
RoundedWhiteContainer(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Text(
"You do not have any tokens",
style: STextStyles.itemSubtitle(context),
),
),
),
],
);
}
}

View file

@ -11,6 +11,7 @@ class WalletNavigationBar extends StatelessWidget {
required this.onSendPressed,
required this.onExchangePressed,
required this.onBuyPressed,
required this.onTokensPressed,
required this.height,
required this.enableExchange,
}) : super(key: key);
@ -19,6 +20,7 @@ class WalletNavigationBar extends StatelessWidget {
final VoidCallback onSendPressed;
final VoidCallback onExchangePressed;
final VoidCallback onBuyPressed;
final VoidCallback onTokensPressed;
final double height;
final bool enableExchange;
@ -231,6 +233,44 @@ class WalletNavigationBar extends StatelessWidget {
// ),
// ),
// ),
RawMaterialButton(
constraints: const BoxConstraints(
minWidth: 66,
),
onPressed: onTokensPressed,
splashColor:
Theme.of(context).extension<StackColors>()!.highlight,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(
height / 2.0,
),
),
child: Container(
color: Colors.transparent,
child: Padding(
padding: const EdgeInsets.symmetric(vertical: 2.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
const Spacer(),
SvgPicture.asset(
Assets.svg.tokens,
width: 24,
height: 24,
),
const SizedBox(
height: 4,
),
Text(
"Tokens",
style: STextStyles.buttonSmall(context),
),
const Spacer(),
],
),
),
),
),
],
),
),

View file

@ -14,6 +14,7 @@ import 'package:stackwallet/pages/receive_view/receive_view.dart';
import 'package:stackwallet/pages/send_view/send_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_network_settings_view/wallet_network_settings_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_view.dart';
import 'package:stackwallet/pages/token_view/my_tokens_view.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/transactions_list.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_navigation_bar.dart';
import 'package:stackwallet/pages/wallet_view/sub_widgets/wallet_summary.dart';
@ -776,6 +777,12 @@ class _WalletViewState extends ConsumerState<WalletView> {
);
},
onBuyPressed: () {},
onTokensPressed: () {
Navigator.of(context).pushNamed(
MyTokensView.routeName,
arguments: walletId,
);
},
),
),
),

View file

@ -78,6 +78,7 @@ import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_set
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/rename_wallet_view.dart';
import 'package:stackwallet/pages/settings_views/wallet_settings_view/wallet_settings_wallet_settings/wallet_settings_wallet_settings_view.dart';
import 'package:stackwallet/pages/stack_privacy_calls.dart';
import 'package:stackwallet/pages/token_view/my_tokens_view.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/all_transactions_view.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/edit_note_view.dart';
import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_details_view.dart';
@ -1292,6 +1293,20 @@ class RouteGenerator {
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
case MyTokensView.routeName:
if (args is String) {
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => MyTokensView(
walletId: args,
),
settings: RouteSettings(
name: settings.name,
),
);
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
// == End of desktop specific routes =====================================
default:

View file

@ -167,6 +167,8 @@ class _SVG {
String get exitDesktop => "assets/svg/exit-desktop.svg";
String get keys => "assets/svg/keys.svg";
String get arrowDown => "assets/svg/arrow-down.svg";
String get tokens => "assets/svg/tokens.svg";
String get circlePlusDark => "assets/svg/circle-plus.svg";
String get ellipse1 => "assets/svg/Ellipse-43.svg";
String get ellipse2 => "assets/svg/Ellipse-42.svg";

View file

@ -306,6 +306,8 @@ flutter:
- assets/svg/arrow-down.svg
- assets/svg/plus-circle.svg
- assets/svg/configuration.svg
- assets/svg/tokens.svg
- assets/svg/circle-plus.svg
# coin icons
- assets/svg/coin_icons/Bitcoin.svg
- assets/svg/coin_icons/Litecoin.svg