CakeWallet/lib/src/screens/dashboard/pages/cake_features_page.dart
Serhii 30dc8f9238
Cw 591 in app cake pay integration (#1376)
* init commit

* buy card UI

* buy card detail page

* card filter

* dropdown button

* user auth flow

* create order

* denomination option

* fix searching

* denom option fix UI

* simulate payment

* Update pr_test_build.yml

* Update pr_test_build.yml

* Implement order expiration handling [skip ci]

* refactor code [skip ci]

* remove ionia related code [skip ci]

* change auth flow

* add currency prefix

* grid view UI

* fix country filter issue

* fix underline color

* fix fetching card list [skip ci]

* list view

* update cake pay title

* Optimize API usage by fetching CakePay vendors

* handle no cards found case

* adjust the flow of purchases

* UI fixes

* fix btc payment data

* link extractor

* fix fetch next page issue

* UI fixes

* fix text size

* revert base page changes

* Revert "revert base page changes"

* UI fixes

* fix UI

* fix link style + localization

* update cake pay title

* update cake pay subtitle

* Update cake_pay_order.dart

* revert inject_app_details update
2024-06-06 06:51:22 +02:00

107 lines
3.7 KiB
Dart

import 'package:cake_wallet/generated/i18n.dart';
import 'package:cake_wallet/routes.dart';
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
import 'package:cake_wallet/src/widgets/dashboard_card_widget.dart';
import 'package:cake_wallet/themes/extensions/dashboard_page_theme.dart';
import 'package:cake_wallet/utils/show_pop_up.dart';
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cake_wallet/view_model/dashboard/cake_features_view_model.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:flutter_svg/flutter_svg.dart';
class CakeFeaturesPage extends StatelessWidget {
CakeFeaturesPage({required this.dashboardViewModel, required this.cakeFeaturesViewModel});
final DashboardViewModel dashboardViewModel;
final CakeFeaturesViewModel cakeFeaturesViewModel;
final _scrollController = ScrollController();
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: RawScrollbar(
thumbColor: Colors.white.withOpacity(0.15),
radius: Radius.circular(20),
thumbVisibility: true,
thickness: 2,
controller: _scrollController,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
SizedBox(height: 50),
Text(
'Cake ${S.of(context).features}',
style: TextStyle(
fontSize: 24,
fontWeight: FontWeight.w500,
color: Theme.of(context).extension<DashboardPageTheme>()!.pageTitleTextColor,
),
),
Expanded(
child: ListView(
controller: _scrollController,
children: <Widget>[
SizedBox(height: 20),
DashBoardRoundedCardWidget(
onTap: () => _navigatorToGiftCardsPage(context),
title: 'Cake Pay',
subTitle: S.of(context).cake_pay_subtitle,
svgPicture: SvgPicture.asset(
'assets/images/cards.svg',
height: 125,
width: 125,
fit: BoxFit.cover,
),
),
SizedBox(height: 10),
DashBoardRoundedCardWidget(
title: "NanoGPT",
subTitle: S.of(context).nanogpt_subtitle,
onTap: () => _launchUrl("cake.nano-gpt.com"),
),
],
),
),
],
),
),
),
);
}
void _launchUrl(String url) {
try {
launchUrl(
Uri.https(url),
mode: LaunchMode.externalApplication,
);
} catch (e) {
print(e);
}
}
void _navigatorToGiftCardsPage(BuildContext context) {
final walletType = dashboardViewModel.type;
switch (walletType) {
case WalletType.haven:
showPopUp<void>(
context: context,
builder: (BuildContext context) {
return AlertWithOneAction(
alertTitle: S.of(context).error,
alertContent: S.of(context).gift_cards_unavailable,
buttonText: S.of(context).ok,
buttonAction: () => Navigator.of(context).pop());
});
break;
default:
Navigator.pushNamed(context, Routes.cakePayCardsPage);
}
}
}