add basic buy page

This commit is contained in:
sneurlax 2023-01-04 10:49:13 -06:00
parent 02ab644baf
commit 0ee2357c60
9 changed files with 182 additions and 32 deletions

View file

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.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_view.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();

View file

@ -123,37 +123,45 @@ class _HomeViewButtonBarState extends ConsumerState<HomeViewButtonBar> {
),
),
),
// TODO: Do not delete this code.
// only temporarily disabled
// SizedBox(
// width: 8,
// ),
// Expanded(
// child: TextButton(
// style: ButtonStyle(
// minimumSize: MaterialStateProperty.all<Size>(Size(46, 36)),
// backgroundColor: MaterialStateProperty.all<Color>(
// selectedIndex == 2
// ? CFColors.stackAccent
// : CFColors.disabledButton,
// ),
// ),
// onPressed: () {
// FocusScope.of(context).unfocus();
// if (selectedIndex != 2) {
// ref.read(homeViewPageIndexStateProvider.state).state = 2;
// }
// },
// child: Text(
// "Buy",
// style: STextStyles.button(context).copyWith(
// fontSize: 14,
// color:
// selectedIndex == 2 ? CFColors.light1 : Theme.of(context).extension<StackColors>()!.accentColorDark
// ),
// ),
// ),
// ),
SizedBox(
width: 8,
),
Expanded(
child: TextButton(
style: selectedIndex == 2
? Theme.of(context)
.extension<StackColors>()!
.getPrimaryEnabledButtonColor(context)!
.copyWith(
minimumSize:
MaterialStateProperty.all<Size>(const Size(46, 36)),
)
: Theme.of(context)
.extension<StackColors>()!
.getSecondaryEnabledButtonColor(context)!
.copyWith(
minimumSize:
MaterialStateProperty.all<Size>(const Size(46, 36)),
),
onPressed: () async {
FocusScope.of(context).unfocus();
if (selectedIndex != 2) {
ref.read(homeViewPageIndexStateProvider.state).state = 2;
}
},
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,
),
),
),
),
],
);
}

View 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(),
// ),
// ],
// ),
// ),
],
),
),
);
}
}

View file

@ -1,6 +1,7 @@
import 'package:flutter/material.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/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_menu.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,
initialRoute: DesktopExchangeView.routeName,
),
DesktopMenuItemId.buy: const Navigator(
key: Key("desktopBuyHomeKey"),
onGenerateRoute: RouteGenerator.generateRoute,
initialRoute: DesktopBuyView.routeName,
),
DesktopMenuItemId.notifications: const Navigator(
key: Key("desktopNotificationsHomeKey"),
onGenerateRoute: RouteGenerator.generateRoute,

View file

@ -12,6 +12,7 @@ import 'package:stackwallet/widgets/desktop/living_stack_icon.dart';
enum DesktopMenuItemId {
myStack,
exchange,
buy,
notifications,
addressBook,
settings,
@ -73,6 +74,7 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
DMIController(),
DMIController(),
DMIController(),
DMIController(),
];
super.initState();
@ -157,6 +159,17 @@ class _DesktopMenuState extends ConsumerState<DesktopMenu> {
const SizedBox(
height: 2,
),
DesktopMenuItem(
duration: duration,
icon: const DesktopBuyIcon(),
label: "Buy",
value: DesktopMenuItemId.buy,
onChanged: updateSelectedMenuItem,
controller: controllers[2],
),
const SizedBox(
height: 2,
),
DesktopMenuItem(
duration: duration,
icon: const DesktopNotificationsIcon(),

View file

@ -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 {
const DesktopNotificationsIcon({Key? key}) : super(key: key);

View file

@ -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/wallets_view/wallets_view.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_exchange_view.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
@ -1061,6 +1063,12 @@ class RouteGenerator {
builder: (_) => const DesktopExchangeView(),
settings: RouteSettings(name: settings.name));
case DesktopBuyView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => const DesktopBuyView(),
settings: RouteSettings(name: settings.name));
case DesktopAllTradesView.routeName:
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,

View file

@ -9,6 +9,7 @@ abstract class Assets {
static const lottie = _ANIMATIONS();
static const socials = _SOCIALS();
static const exchange = _EXCHANGE();
static const buy = _BUY();
}
class _SOCIALS {
@ -27,6 +28,12 @@ class _EXCHANGE {
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 {
const _SVG();
String? background(BuildContext context) {
@ -162,6 +169,7 @@ class _SVG {
String get anonymizeFailed => "assets/svg/tx-icon-anonymize-failed.svg";
String get addressBookDesktop => "assets/svg/address-book-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 walletDesktop => "assets/svg/wallet-desktop.svg";
String get exitDesktop => "assets/svg/exit-desktop.svg";

View file

@ -21,6 +21,7 @@ abstract class Constants {
}
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?
static const int _satsPerCoinMonero = 1000000000000;