mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-10 21:04:53 +00:00
Add usage instruction to gift card.
This commit is contained in:
parent
3b61edcc5a
commit
d47887e1ec
2 changed files with 50 additions and 9 deletions
|
@ -1,5 +1,20 @@
|
|||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class IoniaGiftCardInstruction {
|
||||
IoniaGiftCardInstruction(this.header, this.body);
|
||||
|
||||
factory IoniaGiftCardInstruction.fromJsonMap(Map<String, dynamic> element) {
|
||||
return IoniaGiftCardInstruction(
|
||||
element['header'] as String,
|
||||
element['body'] as String);
|
||||
}
|
||||
|
||||
final String header;
|
||||
final String body;
|
||||
}
|
||||
|
||||
class IoniaGiftCard {
|
||||
IoniaGiftCard({
|
||||
@required this.id,
|
||||
|
@ -26,6 +41,11 @@ class IoniaGiftCard {
|
|||
@required this.logoUrl});
|
||||
|
||||
factory IoniaGiftCard.fromJsonMap(Map<String, dynamic> element) {
|
||||
final decodedInstructions = json.decode(element['UsageInstructions'] as String) as Map<String, dynamic>;
|
||||
final instruction = decodedInstructions['instruction'] as List<dynamic>;
|
||||
final instructions = instruction
|
||||
.map((dynamic e) =>IoniaGiftCardInstruction.fromJsonMap(e as Map<String, dynamic>))
|
||||
.toList();
|
||||
return IoniaGiftCard(
|
||||
id: element['Id'] as int,
|
||||
merchantId: element['MerchantId'] as int,
|
||||
|
@ -44,7 +64,8 @@ class IoniaGiftCard {
|
|||
isEmpty: element['IsEmpty'] as bool,
|
||||
logoUrl: element['LogoUrl'] as String,
|
||||
createdDateFormatted: element['CreatedDate'] as String,
|
||||
lastTransactionDateFormatted: element['LastTransactionDate'] as String);
|
||||
lastTransactionDateFormatted: element['LastTransactionDate'] as String,
|
||||
usageInstructions: instructions);
|
||||
}
|
||||
|
||||
final int id;
|
||||
|
@ -54,7 +75,7 @@ class IoniaGiftCard {
|
|||
final String barcodeUrl;
|
||||
final String cardNumber;
|
||||
final String cardPin;
|
||||
final Map<String, dynamic> usageInstructions;
|
||||
final List<IoniaGiftCardInstruction> usageInstructions;
|
||||
final Map<String, dynamic> balanceInstructions;
|
||||
final Map<String, dynamic> paymentInstructions;
|
||||
final String cardImageUrl;
|
||||
|
|
|
@ -157,15 +157,35 @@ class IoniaGiftCardDetailPage extends BasePage {
|
|||
color: Theme.of(context).textTheme.body1.color,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 24),
|
||||
Align(
|
||||
alignment: Alignment.bottomLeft,
|
||||
child: Text(
|
||||
'',
|
||||
style: textMedium(
|
||||
color: Theme.of(context).textTheme.display2.color,
|
||||
),
|
||||
),
|
||||
child: Container(
|
||||
constraints: BoxConstraints(
|
||||
maxHeight: MediaQuery.of(context).size.height * 0.5),
|
||||
child: Expanded(
|
||||
child: ListView.builder(
|
||||
itemCount: viewModel.giftCard.usageInstructions.length,
|
||||
itemBuilder: (_, int index) {
|
||||
final instruction = viewModel.giftCard.usageInstructions[index];
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: Text(
|
||||
instruction.header,
|
||||
style: textLargeSemiBold(
|
||||
color: Theme.of(context).textTheme.display2.color,
|
||||
),
|
||||
)),
|
||||
Text(
|
||||
instruction.body,
|
||||
style: textMedium(
|
||||
color: Theme.of(context).textTheme.display2.color,
|
||||
),
|
||||
)
|
||||
]));
|
||||
})))
|
||||
),
|
||||
SizedBox(height: 35),
|
||||
PrimaryButton(
|
||||
|
|
Loading…
Reference in a new issue