CAKE-356 | added "Manage Yats" item to the settings page; reworked primary icon button; added yat address to qr widget; created yat_alert.dart, yat_webview_page.dart, yat_store.dart, yat_view_model.dart, yat_exception.dart, yat_record.dart
parent
a2206f6fbd
commit
92aece5e31
After Width: | Height: | Size: 420 KiB |
After Width: | Height: | Size: 1.1 KiB |
@ -0,0 +1,27 @@
|
||||
import 'package:cake_wallet/src/screens/yat/widgets/yat_close_button.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class YatBar extends StatelessWidget {
|
||||
YatBar({this.onClose});
|
||||
|
||||
final VoidCallback onClose;
|
||||
final image = Image.asset('assets/images/yat_logo.png');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Stack(
|
||||
alignment: Alignment.bottomCenter,
|
||||
children: [
|
||||
Positioned(
|
||||
top: 0,
|
||||
right: 0,
|
||||
child: YatCloseButton(onClose: onClose)
|
||||
),
|
||||
Positioned(
|
||||
top: 16,
|
||||
child: image
|
||||
)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class YatCloseButton extends StatelessWidget {
|
||||
YatCloseButton({this.onClose});
|
||||
|
||||
final VoidCallback onClose;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onClose,
|
||||
child: Container(
|
||||
height: 28,
|
||||
width: 28,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Palette.manatee,
|
||||
shape: BoxShape.circle
|
||||
),
|
||||
child: Icon(
|
||||
Icons.clear,
|
||||
color: Colors.white,
|
||||
size: 20)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/yat/widgets/yat_bar.dart';
|
||||
import 'package:cake_wallet/src/screens/yat/yat_webview_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
|
||||
class YatAlert extends StatelessWidget {
|
||||
static const aspectRatioImage = 1.133;
|
||||
final image = Image.asset('assets/images/yat_crypto.png');
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final screenHeight = MediaQuery.of(context).size.height;
|
||||
final screenWidth = MediaQuery.of(context).size.width;
|
||||
|
||||
return Container(
|
||||
height: screenHeight,
|
||||
width: screenWidth,
|
||||
color: Colors.white,
|
||||
child: ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.only(top: 40, bottom: 40),
|
||||
content: Column(
|
||||
children: [
|
||||
Container(
|
||||
height: 90,
|
||||
padding: EdgeInsets.only(left: 24, right: 24),
|
||||
child: YatBar(onClose: () => Navigator.of(context).pop())
|
||||
),
|
||||
AspectRatio(
|
||||
aspectRatio: aspectRatioImage,
|
||||
child: FittedBox(child: image, fit: BoxFit.fill)
|
||||
),
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 30, right: 30),
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
'Send and receive crypto more easily with Yat',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 24,
|
||||
fontWeight: FontWeight.bold,
|
||||
fontFamily: 'Lato',
|
||||
color: Colors.black,
|
||||
decoration: TextDecoration.none,
|
||||
)
|
||||
),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 20),
|
||||
child: Text(
|
||||
'Cake Wallet users can now send and receive all their favorite currencies with a one-of-a-kind emoji-based username.',
|
||||
textAlign: TextAlign.center,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.normal,
|
||||
fontFamily: 'Lato',
|
||||
color: Colors.black,
|
||||
decoration: TextDecoration.none,
|
||||
)
|
||||
)
|
||||
)
|
||||
]
|
||||
)
|
||||
)
|
||||
]
|
||||
),
|
||||
bottomSectionPadding: EdgeInsets.fromLTRB(24, 0, 24, 40),
|
||||
bottomSection: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
PrimaryIconButton(
|
||||
text: 'Get your Yat',
|
||||
textColor: Colors.white,
|
||||
color: Palette.protectiveBlue,
|
||||
borderColor: Palette.protectiveBlue,
|
||||
iconColor: Colors.white,
|
||||
iconBackgroundColor: Colors.transparent,
|
||||
iconData: CupertinoIcons
|
||||
.arrow_up_right_square,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
onPressed: () => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.yat, arguments: YatMode.create)),
|
||||
Padding(
|
||||
padding: EdgeInsets.only(top: 24),
|
||||
child: PrimaryIconButton(
|
||||
text: 'Connect an existing Yat',
|
||||
textColor: Colors.black,
|
||||
color: Palette.blueAlice,
|
||||
borderColor: Palette.blueAlice,
|
||||
iconColor: Colors.black,
|
||||
iconBackgroundColor: Colors.transparent,
|
||||
iconData: CupertinoIcons
|
||||
.arrow_up_right_square,
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
onPressed: () => Navigator.of(context)
|
||||
.popAndPushNamed(Routes.yat, arguments: YatMode.connect))
|
||||
)
|
||||
]
|
||||
),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/view_model/yat_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:webview_flutter/webview_flutter.dart';
|
||||
|
||||
enum YatMode {create, connect}
|
||||
|
||||
class YatWebViewPage extends BasePage {
|
||||
YatWebViewPage({this.yatViewModel, this.mode}) {
|
||||
switch (mode) {
|
||||
case YatMode.create:
|
||||
url = _baseUrl + _createSuffix;
|
||||
break;
|
||||
case YatMode.connect:
|
||||
url = _baseUrl + _signInSuffix;
|
||||
break;
|
||||
default:
|
||||
url = _baseUrl + _createSuffix;
|
||||
}
|
||||
}
|
||||
|
||||
static const _baseUrl = 'https://y.at';
|
||||
static const _signInSuffix = '/sign-in';
|
||||
static const _createSuffix = '/create';
|
||||
|
||||
final YatMode mode;
|
||||
final YatViewModel yatViewModel;
|
||||
|
||||
String url;
|
||||
|
||||
@override
|
||||
String get title => 'Yat';
|
||||
|
||||
@override
|
||||
Color get backgroundDarkColor => Colors.white;
|
||||
|
||||
@override
|
||||
Color get titleColor => Palette.darkBlueCraiola;
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) => WebView(
|
||||
initialUrl: url,
|
||||
javascriptMode: JavascriptMode.unrestricted);
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
part 'yat_store.g.dart';
|
||||
|
||||
class YatStore = YatStoreBase with _$YatStore;
|
||||
|
||||
abstract class YatStoreBase with Store {
|
||||
YatStoreBase() : yatAddress = '';
|
||||
|
||||
@observable
|
||||
String yatAddress;
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
import 'package:cake_wallet/store/yat_store.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'dart:convert';
|
||||
import 'package:cake_wallet/yat/yat_exception.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
part 'yat_view_model.g.dart';
|
||||
|
||||
class YatViewModel = YatViewModelBase with _$YatViewModel;
|
||||
|
||||
abstract class YatViewModelBase with Store {
|
||||
YatViewModelBase({@required this.yatStore});
|
||||
|
||||
final YatStore yatStore;
|
||||
|
||||
Future<void> fetchCartInfo() async {
|
||||
const _apiKey = ''; // FIXME
|
||||
|
||||
final url = 'https://api.y.at/cart';
|
||||
|
||||
final response = await get(
|
||||
url,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Authorization,X-Api-Key': _apiKey
|
||||
}
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw YatException(text: response.body.toString());
|
||||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
yatStore.yatAddress = responseJSON[''] as String; // FIXME
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class YatException implements Exception {
|
||||
YatException({@required this.text});
|
||||
|
||||
final String text;
|
||||
|
||||
@override
|
||||
String toString() => 'Yat exception: $text';
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
import 'dart:convert';
|
||||
import 'package:cake_wallet/yat/yat_exception.dart';
|
||||
import 'package:http/http.dart';
|
||||
|
||||
Future<String> fetchYatAddress(String emojiId) async {
|
||||
const _apiKey = ''; // FIXME
|
||||
const _requestURL = 'https://api.y.at/emoji_id/';
|
||||
|
||||
final url = _requestURL + emojiId;
|
||||
|
||||
final response = await get(
|
||||
url,
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Authorization': 'Bearer $_apiKey'
|
||||
}
|
||||
);
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw YatException(text: response.body.toString());
|
||||
}
|
||||
|
||||
final responseJSON = json.decode(response.body) as Map<String, dynamic>;
|
||||
final yatAddress = responseJSON[''] as String; // FIXME
|
||||
return yatAddress;
|
||||
}
|
Loading…
Reference in new issue