mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-01-26 20:26:02 +00:00
add basic buy page
This commit is contained in:
parent
02ab644baf
commit
0ee2357c60
9 changed files with 182 additions and 32 deletions
|
@ -3,6 +3,7 @@ import 'dart:async';
|
||||||
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/buy_view/buy_view.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/exchange_loading_overlay.dart';
|
import 'package:stackwallet/pages/exchange_view/exchange_loading_overlay.dart';
|
||||||
import 'package:stackwallet/pages/exchange_view/exchange_view.dart';
|
import 'package:stackwallet/pages/exchange_view/exchange_view.dart';
|
||||||
import 'package:stackwallet/pages/home_view/sub_widgets/home_view_button_bar.dart';
|
import 'package:stackwallet/pages/home_view/sub_widgets/home_view_button_bar.dart';
|
||||||
|
@ -106,7 +107,14 @@ class _HomeViewState extends ConsumerState<HomeView> {
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
// const BuyView(),
|
if (Constants.enableBuy)
|
||||||
|
// Stack(
|
||||||
|
// children: [
|
||||||
|
const BuyView(),
|
||||||
|
// BuyLoadingOverlayView(
|
||||||
|
// unawaitedLoad: _loadSimplexData,
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
];
|
];
|
||||||
|
|
||||||
ref.read(notificationsProvider).startCheckingWatchedNotifications();
|
ref.read(notificationsProvider).startCheckingWatchedNotifications();
|
||||||
|
|
|
@ -123,37 +123,45 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// TODO: Do not delete this code.
|
SizedBox(
|
||||||
// only temporarily disabled
|
width: 8,
|
||||||
// SizedBox(
|
),
|
||||||
// width: 8,
|
Expanded(
|
||||||
// ),
|
child: TextButton(
|
||||||
// Expanded(
|
style: selectedIndex == 2
|
||||||
// child: TextButton(
|
? Theme.of(context)
|
||||||
// style: ButtonStyle(
|
.extension<StackColors>()!
|
||||||
// minimumSize: MaterialStateProperty.all<Size>(Size(46, 36)),
|
.getPrimaryEnabledButtonColor(context)!
|
||||||
// backgroundColor: MaterialStateProperty.all<Color>(
|
.copyWith(
|
||||||
// selectedIndex == 2
|
minimumSize:
|
||||||
// ? CFColors.stackAccent
|
MaterialStateProperty.all<Size>(const Size(46, 36)),
|
||||||
// : CFColors.disabledButton,
|
)
|
||||||
// ),
|
: Theme.of(context)
|
||||||
// ),
|
.extension<StackColors>()!
|
||||||
// onPressed: () {
|
.getSecondaryEnabledButtonColor(context)!
|
||||||
// FocusScope.of(context).unfocus();
|
.copyWith(
|
||||||
// if (selectedIndex != 2) {
|
minimumSize:
|
||||||
// ref.read(homeViewPageIndexStateProvider.state).state = 2;
|
MaterialStateProperty.all<Size>(const Size(46, 36)),
|
||||||
// }
|
),
|
||||||
// },
|
onPressed: () async {
|
||||||
// child: Text(
|
FocusScope.of(context).unfocus();
|
||||||
// "Buy",
|
if (selectedIndex != 2) {
|
||||||
// style: STextStyles.button(context).copyWith(
|
ref.read(homeViewPageIndexStateProvider.state).state = 2;
|
||||||
// fontSize: 14,
|
}
|
||||||
// color:
|
},
|
||||||
// selectedIndex == 2 ? CFColors.light1 : Theme.of(context).extension<StackColors>()!.accentColorDark
|
child: Text(
|
||||||
// ),
|
"Buy",
|
||||||
// ),
|
style: STextStyles.button(context).copyWith(
|
||||||
// ),
|
fontSize: 14,
|
||||||
// ),
|
color: selectedIndex == 1
|
||||||
|
? Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.buttonTextPrimary
|
||||||
|
: Theme.of(context).extension<StackColors>()!.textDark,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
78
lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart
Normal file
78
lib/pages_desktop_specific/desktop_buy/desktop_buy_view.dart
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
import 'package:flutter/material.dart';
|
||||||
|
// import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
||||||
|
// import 'package:stackwallet/pages_desktop_specific/desktop_buy/subwidgets/desktop_buy_history.dart';
|
||||||
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||||
|
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||||
|
|
||||||
|
class DesktopBuyView extends StatefulWidget {
|
||||||
|
const DesktopBuyView({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
static const String routeName = "/desktopBuy";
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<DesktopBuyView> createState() => _DesktopBuyViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DesktopBuyViewState extends State<DesktopBuyView> {
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return DesktopScaffold(
|
||||||
|
appBar: DesktopAppBar(
|
||||||
|
isCompactHeight: true,
|
||||||
|
leading: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 24,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"Buy",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 24,
|
||||||
|
right: 24,
|
||||||
|
bottom: 24,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Coming soon",
|
||||||
|
style: STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
// const RoundedWhiteContainer(
|
||||||
|
// padding: EdgeInsets.all(24),
|
||||||
|
// child: BuyForm(),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
// Expanded(
|
||||||
|
// child: Row(
|
||||||
|
// children: const [
|
||||||
|
// Expanded(
|
||||||
|
// child: DesktopTradeHistory(),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
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/pages_desktop_specific/address_book_view/desktop_address_book.dart';
|
import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/desktop_buy/desktop_buy_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_menu.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/my_stack_view/my_stack_view.dart';
|
||||||
|
@ -56,6 +57,11 @@ class _DesktopHomeViewState extends ConsumerState<DesktopHomeView> {
|
||||||
onGenerateRoute: RouteGenerator.generateRoute,
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
initialRoute: DesktopExchangeView.routeName,
|
initialRoute: DesktopExchangeView.routeName,
|
||||||
),
|
),
|
||||||
|
DesktopMenuItemId.buy: const Navigator(
|
||||||
|
key: Key("desktopBuyHomeKey"),
|
||||||
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
|
initialRoute: DesktopBuyView.routeName,
|
||||||
|
),
|
||||||
DesktopMenuItemId.notifications: const Navigator(
|
DesktopMenuItemId.notifications: const Navigator(
|
||||||
key: Key("desktopNotificationsHomeKey"),
|
key: Key("desktopNotificationsHomeKey"),
|
||||||
onGenerateRoute: RouteGenerator.generateRoute,
|
onGenerateRoute: RouteGenerator.generateRoute,
|
||||||
|
|
|
@ -12,6 +12,7 @@ import 'package:stackwallet/widgets/desktop/living_stack_icon.dart';
|
||||||
enum DesktopMenuItemId {
|
enum DesktopMenuItemId {
|
||||||
myStack,
|
myStack,
|
||||||
exchange,
|
exchange,
|
||||||
|
buy,
|
||||||
notifications,
|
notifications,
|
||||||
addressBook,
|
addressBook,
|
||||||
settings,
|
settings,
|
||||||
|
@ -73,6 +74,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
||||||
DMIController(),
|
DMIController(),
|
||||||
DMIController(),
|
DMIController(),
|
||||||
DMIController(),
|
DMIController(),
|
||||||
|
DMIController(),
|
||||||
];
|
];
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
|
@ -157,6 +159,17 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
|
||||||
const SizedBox(
|
const SizedBox(
|
||||||
height: 2,
|
height: 2,
|
||||||
),
|
),
|
||||||
|
DesktopMenuItem(
|
||||||
|
duration: duration,
|
||||||
|
icon: const DesktopBuyIcon(),
|
||||||
|
label: "Buy",
|
||||||
|
value: DesktopMenuItemId.buy,
|
||||||
|
onChanged: updateSelectedMenuItem,
|
||||||
|
controller: controllers[2],
|
||||||
|
),
|
||||||
|
const SizedBox(
|
||||||
|
height: 2,
|
||||||
|
),
|
||||||
DesktopMenuItem(
|
DesktopMenuItem(
|
||||||
duration: duration,
|
duration: duration,
|
||||||
icon: const DesktopNotificationsIcon(),
|
icon: const DesktopNotificationsIcon(),
|
||||||
|
|
|
@ -55,6 +55,26 @@ class DesktopExchangeIcon extends ConsumerWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class DesktopBuyIcon extends ConsumerWidget {
|
||||||
|
const DesktopBuyIcon({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
|
return SvgPicture.asset(
|
||||||
|
Assets.svg.buyDesktop,
|
||||||
|
width: 20,
|
||||||
|
height: 20,
|
||||||
|
color: DesktopMenuItemId.buy ==
|
||||||
|
ref.watch(currentDesktopMenuItemProvider.state).state
|
||||||
|
? Theme.of(context).extension<StackColors>()!.accentColorDark
|
||||||
|
: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.accentColorDark
|
||||||
|
.withOpacity(0.8),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DesktopNotificationsIcon extends ConsumerWidget {
|
class DesktopNotificationsIcon extends ConsumerWidget {
|
||||||
const DesktopNotificationsIcon({Key? key}) : super(key: key);
|
const DesktopNotificationsIcon({Key? key}) : super(key: key);
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ import 'package:stackwallet/pages/wallet_view/transaction_views/transaction_sear
|
||||||
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
import 'package:stackwallet/pages/wallet_view/wallet_view.dart';
|
||||||
import 'package:stackwallet/pages/wallets_view/wallets_view.dart';
|
import 'package:stackwallet/pages/wallets_view/wallets_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart';
|
import 'package:stackwallet/pages_desktop_specific/address_book_view/desktop_address_book.dart';
|
||||||
|
// import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_buys_view.dart';
|
||||||
|
import 'package:stackwallet/pages_desktop_specific/desktop_buy/desktop_buy_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_all_trades_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_exchange/desktop_exchange_view.dart';
|
||||||
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
|
||||||
|
@ -1061,6 +1063,12 @@ class RouteGenerator {
|
||||||
builder: (_) => const DesktopExchangeView(),
|
builder: (_) => const DesktopExchangeView(),
|
||||||
settings: RouteSettings(name: settings.name));
|
settings: RouteSettings(name: settings.name));
|
||||||
|
|
||||||
|
case DesktopBuyView.routeName:
|
||||||
|
return getRoute(
|
||||||
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
|
builder: (_) => const DesktopBuyView(),
|
||||||
|
settings: RouteSettings(name: settings.name));
|
||||||
|
|
||||||
case DesktopAllTradesView.routeName:
|
case DesktopAllTradesView.routeName:
|
||||||
return getRoute(
|
return getRoute(
|
||||||
shouldUseMaterialRoute: useMaterialPageRoute,
|
shouldUseMaterialRoute: useMaterialPageRoute,
|
||||||
|
|
|
@ -9,6 +9,7 @@ abstract class Assets {
|
||||||
static const lottie = _ANIMATIONS();
|
static const lottie = _ANIMATIONS();
|
||||||
static const socials = _SOCIALS();
|
static const socials = _SOCIALS();
|
||||||
static const exchange = _EXCHANGE();
|
static const exchange = _EXCHANGE();
|
||||||
|
static const buy = _BUY();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _SOCIALS {
|
class _SOCIALS {
|
||||||
|
@ -27,6 +28,12 @@ class _EXCHANGE {
|
||||||
String get simpleSwap => "assets/svg/exchange_icons/simpleswap-icon.svg";
|
String get simpleSwap => "assets/svg/exchange_icons/simpleswap-icon.svg";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class _BUY {
|
||||||
|
const _BUY();
|
||||||
|
|
||||||
|
String get buy => "assets/svg/light/buy-coins-icon.svg";
|
||||||
|
}
|
||||||
|
|
||||||
class _SVG {
|
class _SVG {
|
||||||
const _SVG();
|
const _SVG();
|
||||||
String? background(BuildContext context) {
|
String? background(BuildContext context) {
|
||||||
|
@ -162,6 +169,7 @@ class _SVG {
|
||||||
String get anonymizeFailed => "assets/svg/tx-icon-anonymize-failed.svg";
|
String get anonymizeFailed => "assets/svg/tx-icon-anonymize-failed.svg";
|
||||||
String get addressBookDesktop => "assets/svg/address-book-desktop.svg";
|
String get addressBookDesktop => "assets/svg/address-book-desktop.svg";
|
||||||
String get exchangeDesktop => "assets/svg/exchange-desktop.svg";
|
String get exchangeDesktop => "assets/svg/exchange-desktop.svg";
|
||||||
|
String get buyDesktop => "assets/svg/light/buy-coins-icon.svg";
|
||||||
String get aboutDesktop => "assets/svg/about-desktop.svg";
|
String get aboutDesktop => "assets/svg/about-desktop.svg";
|
||||||
String get walletDesktop => "assets/svg/wallet-desktop.svg";
|
String get walletDesktop => "assets/svg/wallet-desktop.svg";
|
||||||
String get exitDesktop => "assets/svg/exit-desktop.svg";
|
String get exitDesktop => "assets/svg/exit-desktop.svg";
|
||||||
|
|
|
@ -21,6 +21,7 @@ abstract class Constants {
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool enableExchange = Util.isDesktop || !Platform.isIOS;
|
static bool enableExchange = Util.isDesktop || !Platform.isIOS;
|
||||||
|
static bool enableBuy = true; // true for development, TODO change to "Util.isDesktop || !Platform.isIOS;" as above or even just = enableExchange
|
||||||
|
|
||||||
//TODO: correct for monero?
|
//TODO: correct for monero?
|
||||||
static const int _satsPerCoinMonero = 1000000000000;
|
static const int _satsPerCoinMonero = 1000000000000;
|
||||||
|
|
Loading…
Reference in a new issue