mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-11 21:34:48 +00:00
Merge branch 'ionia' of github.com:cake-tech/cake_wallet into ionia
This commit is contained in:
commit
aab6d89afa
10 changed files with 133 additions and 63 deletions
18
lib/di.dart
18
lib/di.dart
|
@ -3,6 +3,7 @@ import 'package:cake_wallet/entities/parse_address_from_domain.dart';
|
|||
import 'package:cake_wallet/entities/wake_lock.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_api.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
import 'package:cake_wallet/haven/haven.dart';
|
||||
|
@ -652,8 +653,9 @@ Future setup(
|
|||
|
||||
getIt.registerFactory<IoniaService>(
|
||||
() => IoniaService(getIt.get<FlutterSecureStorage>(), getIt.get<IoniaApi>()));
|
||||
|
||||
getIt.registerFactory(() => IoniaViewModel(ioniaService: getIt.get<IoniaService>()));
|
||||
|
||||
getIt.registerFactory(
|
||||
() => IoniaViewModel(ioniaService: getIt.get<IoniaService>(), ioniaMerchantService: getIt.get<IoniaMerchantService>()));
|
||||
|
||||
getIt.registerFactory(() => IoniaCreateAccountPage(getIt.get<IoniaViewModel>()));
|
||||
|
||||
|
@ -668,9 +670,17 @@ Future setup(
|
|||
|
||||
getIt.registerFactory(() => IoniaWelcomePage(getIt.get<IoniaViewModel>()));
|
||||
|
||||
getIt.registerFactory(() => IoniaBuyGiftCardPage());
|
||||
getIt.registerFactoryParam<IoniaBuyGiftCardPage, List, void>((List args, _) {
|
||||
final merchant = args.first as IoniaMerchant;
|
||||
|
||||
getIt.registerFactory(() => IoniaBuyGiftCardDetailPage());
|
||||
return IoniaBuyGiftCardPage(merchant);
|
||||
});
|
||||
|
||||
getIt.registerFactoryParam<IoniaBuyGiftCardDetailPage, List, void>((List args, _) {
|
||||
final merchant = args.first as IoniaMerchant;
|
||||
|
||||
return IoniaBuyGiftCardDetailPage(merchant);
|
||||
});
|
||||
|
||||
getIt.registerFactory(() => IoniaManageCardsPage(getIt.get<IoniaViewModel>()));
|
||||
|
||||
|
|
|
@ -416,13 +416,15 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaManageCardsPage>());
|
||||
|
||||
case Routes.ioniaBuyGiftCardPage:
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardPage>());
|
||||
final args = settings.arguments as List;
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardPage>(param1: args));
|
||||
|
||||
case Routes.ioniaBuyGiftCardDetailPage:
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardDetailPage>());
|
||||
final args = settings.arguments as List;
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaBuyGiftCardDetailPage>(param1: args));
|
||||
|
||||
case Routes.ioniaVerifyIoniaOtpPage:
|
||||
final args = settings.arguments as List;
|
||||
final args = settings.arguments as List;
|
||||
return CupertinoPageRoute<void>(builder: (_) =>getIt.get<IoniaVerifyIoniaOtp>(param1: args));
|
||||
|
||||
case Routes.ioniaDebitCardPage:
|
||||
|
|
|
@ -30,7 +30,7 @@ class IoniaWelcomePage extends BasePage {
|
|||
Widget body(BuildContext context) {
|
||||
reaction((_) => _ioniaViewModel.isLoggedIn, (bool state) {
|
||||
if (state) {
|
||||
Navigator.pushReplacementNamed(context, Routes.ioniaDebitCardPage);
|
||||
Navigator.pushReplacementNamed(context, Routes.ioniaManageCardsPage);
|
||||
}
|
||||
});
|
||||
return Padding(
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/confirm_modal.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/text_icon_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_two_actions.dart';
|
||||
import 'package:cake_wallet/src/widgets/discount_badge.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
|
@ -14,6 +14,11 @@ import 'package:flutter/material.dart';
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class IoniaBuyGiftCardDetailPage extends StatelessWidget {
|
||||
|
||||
const IoniaBuyGiftCardDetailPage(this.merchant);
|
||||
|
||||
final IoniaMerchant merchant;
|
||||
|
||||
ThemeBase get currentTheme => getIt.get<SettingsStore>().currentTheme;
|
||||
|
||||
Color get backgroundLightColor => Colors.white;
|
||||
|
@ -52,7 +57,7 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget {
|
|||
|
||||
Widget middle(BuildContext context) {
|
||||
return Text(
|
||||
'AppleBees',
|
||||
merchant.legalName,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
fontFamily: 'Lato',
|
||||
|
@ -74,7 +79,7 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget {
|
|||
SizedBox(height: 60),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [leading(context), middle(context), DiscountBadge()],
|
||||
children: [leading(context), middle(context), DiscountBadge(percentage: merchant.minimumDiscount,)],
|
||||
),
|
||||
SizedBox(height: 36),
|
||||
Container(
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/card_item.dart';
|
||||
|
@ -12,9 +13,12 @@ import 'package:keyboard_actions/keyboard_actions.dart';
|
|||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
|
||||
class IoniaBuyGiftCardPage extends BasePage {
|
||||
IoniaBuyGiftCardPage()
|
||||
IoniaBuyGiftCardPage(this.merchant)
|
||||
: _amountFieldFocus = FocusNode(),
|
||||
_amountController = TextEditingController();
|
||||
|
||||
final IoniaMerchant merchant;
|
||||
|
||||
@override
|
||||
String get title => S.current.enter_amount;
|
||||
|
||||
|
@ -93,7 +97,7 @@ class IoniaBuyGiftCardPage extends BasePage {
|
|||
left: _width / 4,
|
||||
),
|
||||
child: Text(
|
||||
'USD: ',
|
||||
'${merchant.acceptedCurrency}: ',
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontWeight: FontWeight.w900,
|
||||
|
@ -107,13 +111,13 @@ class IoniaBuyGiftCardPage extends BasePage {
|
|||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Text(
|
||||
S.of(context).min_amount('5'),
|
||||
S.of(context).min_amount(merchant.minimumCardPurchase.toString()),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryTextTheme.headline.color,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
S.of(context).max_amount('20000'),
|
||||
S.of(context).max_amount(merchant.maximumCardPurchase.toString()),
|
||||
style: TextStyle(
|
||||
color: Theme.of(context).primaryTextTheme.headline.color,
|
||||
),
|
||||
|
@ -127,11 +131,13 @@ class IoniaBuyGiftCardPage extends BasePage {
|
|||
Padding(
|
||||
padding: const EdgeInsets.all(24.0),
|
||||
child: CardItem(
|
||||
onTap: () {},
|
||||
title: 'Applebee’s',
|
||||
hasDiscount: true,
|
||||
subTitle: 'subTitle',
|
||||
logoUrl: '',
|
||||
title: merchant.legalName,
|
||||
backgroundColor: Theme.of(context).accentTextTheme.display4.backgroundColor.withOpacity(0.1),
|
||||
discount: 0.0,
|
||||
titleColor: Theme.of(context).accentTextTheme.display4.backgroundColor,
|
||||
subtitleColor: Theme.of(context).hintColor,
|
||||
subTitle: merchant.isOnline ? S.of(context).online : S.of(context).offline,
|
||||
logoUrl: merchant.logoUrl,
|
||||
),
|
||||
)
|
||||
],
|
||||
|
@ -141,10 +147,10 @@ class IoniaBuyGiftCardPage extends BasePage {
|
|||
Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: PrimaryButton(
|
||||
onPressed: () => Navigator.of(context).pushNamed(Routes.ioniaBuyGiftCardDetailPage),
|
||||
onPressed: () => Navigator.of(context).pushNamed(Routes.ioniaBuyGiftCardDetailPage, arguments: [merchant] ),
|
||||
text: S.of(context).continue_text,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white,
|
||||
textColor: Theme.of(context).primaryTextTheme.body1.color,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 30),
|
||||
|
|
|
@ -8,6 +8,8 @@ import 'package:cake_wallet/view_model/ionia/ionia_view_model.dart';
|
|||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
class IoniaManageCardsPage extends BasePage {
|
||||
IoniaManageCardsPage(this._ioniaViewModel);
|
||||
|
@ -49,7 +51,7 @@ class IoniaManageCardsPage extends BasePage {
|
|||
Widget leading(BuildContext context) {
|
||||
final _backButton = Icon(
|
||||
Icons.arrow_back_ios,
|
||||
color: titleColor ?? Theme.of(context).primaryTextTheme.title.color,
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor,
|
||||
size: 16,
|
||||
);
|
||||
|
||||
|
@ -141,27 +143,43 @@ class IoniaManageCardsPage extends BasePage {
|
|||
),
|
||||
SizedBox(height: 8),
|
||||
Expanded(
|
||||
child: RawScrollbar(
|
||||
thumbColor: Colors.white.withOpacity(0.15),
|
||||
radius: Radius.circular(20),
|
||||
isAlwaysShown: true,
|
||||
thickness: 2,
|
||||
controller: _scrollController,
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.only(left: 2, right: 22),
|
||||
controller: _scrollController,
|
||||
itemCount: 20,
|
||||
separatorBuilder: (_, __) => SizedBox(height: 4),
|
||||
itemBuilder: (_, index) {
|
||||
return CardItem(
|
||||
logoUrl: '',
|
||||
onTap: () => Navigator.of(context).pushNamed(Routes.ioniaBuyGiftCardPage),
|
||||
title: 'Amazon',
|
||||
subTitle: 'Onlin',
|
||||
hasDiscount: true,
|
||||
);
|
||||
},
|
||||
),
|
||||
child: Observer(
|
||||
builder: (_) {
|
||||
final merchantsList = _ioniaViewModel.ioniaMerchants;
|
||||
return RawScrollbar(
|
||||
thumbColor: Colors.white.withOpacity(0.15),
|
||||
radius: Radius.circular(20),
|
||||
isAlwaysShown: true,
|
||||
thickness: 2,
|
||||
controller: _scrollController,
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.only(left: 2, right: 22),
|
||||
controller: _scrollController,
|
||||
itemCount: merchantsList.length,
|
||||
separatorBuilder: (_, __) => SizedBox(height: 4),
|
||||
itemBuilder: (_, index) {
|
||||
final merchant = merchantsList[index];
|
||||
return CardItem(
|
||||
logoUrl: merchant.logoUrl,
|
||||
onTap: () => Navigator.of(context).pushNamed(Routes.ioniaBuyGiftCardPage,
|
||||
arguments: [merchant]),
|
||||
title: merchant.legalName,
|
||||
subTitle: merchant.isOnline ? S.of(context).online : S.of(context).offline,
|
||||
backgroundColor: Theme.of(context).textTheme.title.backgroundColor,
|
||||
titleColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display3
|
||||
.backgroundColor,
|
||||
subtitleColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display2
|
||||
.backgroundColor,
|
||||
discount: merchant.minimumDiscount,
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -1,22 +1,28 @@
|
|||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/widgets/discount_badge.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class CardItem extends StatelessWidget {
|
||||
|
||||
CardItem({
|
||||
@required this.onTap,
|
||||
@required this.title,
|
||||
@required this.subTitle,
|
||||
@required this.backgroundColor,
|
||||
@required this.titleColor,
|
||||
@required this.subtitleColor,
|
||||
this.onTap,
|
||||
this.logoUrl,
|
||||
this.hasDiscount = false,
|
||||
this.discount,
|
||||
|
||||
});
|
||||
|
||||
final VoidCallback onTap;
|
||||
final String title;
|
||||
final String subTitle;
|
||||
final String logoUrl;
|
||||
final bool hasDiscount;
|
||||
final double discount;
|
||||
final Color backgroundColor;
|
||||
final Color titleColor;
|
||||
final Color subtitleColor;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -28,7 +34,7 @@ class CardItem extends StatelessWidget {
|
|||
padding: EdgeInsets.all(12),
|
||||
width: double.infinity,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.black.withOpacity(0.1),
|
||||
color: backgroundColor,
|
||||
borderRadius: BorderRadius.circular(20),
|
||||
border: Border.all(
|
||||
color: Colors.white.withOpacity(0.20),
|
||||
|
@ -57,19 +63,23 @@ class CardItem extends StatelessWidget {
|
|||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: TextStyle(
|
||||
color: Palette.stateGray,
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.w900,
|
||||
SizedBox(
|
||||
width: 200,
|
||||
child: Text(
|
||||
title,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: titleColor,
|
||||
fontSize: 20,
|
||||
fontWeight: FontWeight.w900,
|
||||
),
|
||||
),
|
||||
),
|
||||
SizedBox(height: 5),
|
||||
Text(
|
||||
subTitle,
|
||||
style: TextStyle(
|
||||
color: Palette.niagara ,
|
||||
color: subtitleColor,
|
||||
fontWeight: FontWeight.w500,
|
||||
fontFamily: 'Lato'),
|
||||
)
|
||||
|
@ -78,12 +88,12 @@ class CardItem extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
if (hasDiscount)
|
||||
if (discount != 0.0)
|
||||
Align(
|
||||
alignment: Alignment.topRight,
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 20.0),
|
||||
child: DiscountBadge(),
|
||||
child: DiscountBadge(percentage: discount),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
|
|
@ -5,8 +5,11 @@ import 'package:cake_wallet/generated/i18n.dart';
|
|||
class DiscountBadge extends StatelessWidget {
|
||||
const DiscountBadge({
|
||||
Key key,
|
||||
@required this.percentage,
|
||||
}) : super(key: key);
|
||||
|
||||
final double percentage;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
|
@ -16,7 +19,7 @@ class DiscountBadge extends StatelessWidget {
|
|||
Padding(
|
||||
padding: const EdgeInsets.only(right: 10.0),
|
||||
child: Text(
|
||||
S.of(context).discount('20'),
|
||||
S.of(context).discount(percentage.toString()),
|
||||
style: TextStyle(
|
||||
color: Colors.white,
|
||||
fontSize: 12,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_create_state.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant_service.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_virtual_card.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
part 'ionia_view_model.g.dart';
|
||||
|
@ -7,14 +9,19 @@ part 'ionia_view_model.g.dart';
|
|||
class IoniaViewModel = IoniaViewModelBase with _$IoniaViewModel;
|
||||
|
||||
abstract class IoniaViewModelBase with Store {
|
||||
IoniaViewModelBase({this.ioniaService})
|
||||
|
||||
IoniaViewModelBase({this.ioniaService, this.ioniaMerchantService})
|
||||
: createUserState = IoniaCreateStateSuccess(),
|
||||
otpState = IoniaOtpSendDisabled(),
|
||||
cardState = IoniaNoCardState() {
|
||||
_getCard();
|
||||
cardState = IoniaNoCardState(), ioniaMerchants = [] {
|
||||
_getMerchants().then((value){
|
||||
ioniaMerchants = value;
|
||||
});
|
||||
_getAuthStatus().then((value) => isLoggedIn = value);
|
||||
}
|
||||
|
||||
final IoniaMerchantService ioniaMerchantService;
|
||||
|
||||
final IoniaService ioniaService;
|
||||
|
||||
@observable
|
||||
|
@ -29,6 +36,9 @@ abstract class IoniaViewModelBase with Store {
|
|||
@observable
|
||||
IoniaFetchCardState cardState;
|
||||
|
||||
@observable
|
||||
List<IoniaMerchant> ioniaMerchants;
|
||||
|
||||
@observable
|
||||
String email;
|
||||
|
||||
|
@ -88,4 +98,8 @@ abstract class IoniaViewModelBase with Store {
|
|||
cardState = IoniaFetchCardFailure();
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<IoniaMerchant>> _getMerchants()async{
|
||||
return await ioniaMerchantService.getMerchants();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -594,5 +594,7 @@
|
|||
"by_cake_pay": "by CakePay",
|
||||
"expires": "Expires",
|
||||
"mm": "MM",
|
||||
"yy": "YY"
|
||||
"yy": "YY",
|
||||
"online": "Online",
|
||||
"offline": "Offline"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue