From 9e3a563419941233127e6a6dd7b6c9048e5a33f8 Mon Sep 17 00:00:00 2001
From: OmarHatem28 <omarh.ismail1@gmail.com>
Date: Thu, 30 Jun 2022 18:44:18 +0200
Subject: [PATCH] Add Welcome and Auth screens for Cake Phone

---
 lib/router.dart                               |  14 +++
 lib/routes.dart                               |   2 +
 .../cake_phone/cake_phone_auth_page.dart      | 108 ++++++++++++++++++
 .../cake_phone/cake_phone_welcome_page.dart   |  92 +++++++++++++++
 res/values/strings_en.arb                     |  12 +-
 5 files changed, 227 insertions(+), 1 deletion(-)
 create mode 100644 lib/src/screens/cake_phone/cake_phone_auth_page.dart
 create mode 100644 lib/src/screens/cake_phone/cake_phone_welcome_page.dart

diff --git a/lib/router.dart b/lib/router.dart
index a3c7573ea..74802fac7 100644
--- a/lib/router.dart
+++ b/lib/router.dart
@@ -4,6 +4,7 @@ import 'package:cake_wallet/src/screens/backup/backup_page.dart';
 import 'package:cake_wallet/src/screens/backup/edit_backup_password_page.dart';
 import 'package:cake_wallet/src/screens/buy/buy_webview_page.dart';
 import 'package:cake_wallet/src/screens/buy/pre_order_page.dart';
+import 'package:cake_wallet/src/screens/cake_phone/cake_phone_auth_page.dart';
 import 'package:cake_wallet/src/screens/order_details/order_details_page.dart';
 import 'package:cake_wallet/src/screens/pin_code/pin_code_widget.dart';
 import 'package:cake_wallet/src/screens/restore/restore_from_backup_page.dart';
@@ -63,6 +64,7 @@ import 'package:flutter/services.dart';
 import 'package:cake_wallet/wallet_types.g.dart';
 import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart';
 import 'package:cake_wallet/src/screens/receive/fullscreen_qr_page.dart';
+import 'package:cake_wallet/src/screens/cake_phone/cake_phone_welcome_page.dart';
 
 RouteSettings currentRouteSettings;
 
@@ -401,6 +403,18 @@ Route<dynamic> createRoute(RouteSettings settings) {
                 param2: args['isLight'] as bool,
               ));
 
+    case Routes.cakePhoneWelcome:
+      return MaterialPageRoute<CakePhoneWelcomePage>(
+        builder: (_) => CakePhoneWelcomePage(),
+      );
+
+    case Routes.cakePhoneAuth:
+      final isLogin = settings.arguments as bool ?? false;
+
+      return MaterialPageRoute<CakePhoneWelcomePage>(
+        builder: (_) => CakePhoneAuthPage(isLogin: isLogin),
+      );
+
     default:
       return MaterialPageRoute<void>(
           builder: (_) => Scaffold(
diff --git a/lib/routes.dart b/lib/routes.dart
index 1200d558a..e61a9a0c1 100644
--- a/lib/routes.dart
+++ b/lib/routes.dart
@@ -60,4 +60,6 @@ class Routes {
   static const moneroNewWalletFromWelcome = '/monero_new_wallet';
   static const addressPage = '/address_page';
   static const fullscreenQR = '/fullscreen_qr';
+  static const cakePhoneWelcome = '/cake_phone_welcome';
+  static const cakePhoneAuth = '/cake_phone_auth';
 }
\ No newline at end of file
diff --git a/lib/src/screens/cake_phone/cake_phone_auth_page.dart b/lib/src/screens/cake_phone/cake_phone_auth_page.dart
new file mode 100644
index 000000000..a9ccc2904
--- /dev/null
+++ b/lib/src/screens/cake_phone/cake_phone_auth_page.dart
@@ -0,0 +1,108 @@
+import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:cake_wallet/routes.dart';
+import 'package:cake_wallet/generated/i18n.dart';
+import 'package:cake_wallet/src/widgets/primary_button.dart';
+import 'package:cake_wallet/src/screens/base_page.dart';
+import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
+
+class CakePhoneAuthPage extends BasePage {
+  CakePhoneAuthPage({@required this.isLogin});
+
+  final bool isLogin;
+
+  @override
+  Widget body(BuildContext context) => CakePhoneAuthBody(isLogin);
+
+  @override
+  Widget middle(BuildContext context) {
+    return Text(
+      isLogin ? S.of(context).login : S.of(context).signup,
+      style: TextStyle(
+          fontSize: 22,
+          fontWeight: FontWeight.w600,
+          fontFamily: 'Lato',
+          color: titleColor ?? Theme.of(context).primaryTextTheme.title.color),
+    );
+  }
+}
+
+class CakePhoneAuthBody extends StatefulWidget {
+  CakePhoneAuthBody(this.isLogin);
+
+  final bool isLogin;
+
+  @override
+  CakePhoneAuthBodyState createState() => CakePhoneAuthBodyState();
+}
+
+class CakePhoneAuthBodyState extends State<CakePhoneAuthBody> {
+  final _emailController = TextEditingController();
+
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      padding: EdgeInsets.only(top: 16),
+      child: ScrollableWithBottomSection(
+        contentPadding: EdgeInsets.fromLTRB(24, 100, 24, 20),
+        content: BaseTextFormField(
+          controller: _emailController,
+          keyboardType: TextInputType.emailAddress,
+          maxLines: 1,
+          hintText: S.of(context).emailAddress,
+        ),
+        bottomSectionPadding: EdgeInsets.only(bottom: 24, right: 24, left: 24),
+        bottomSection: Column(
+          children: <Widget>[
+            PrimaryButton(
+              onPressed: () {},
+              text: widget.isLogin ? S.of(context).login : S.of(context).create_account,
+              color: Theme.of(context).accentTextTheme.body2.color,
+              textColor: Colors.white,
+            ),
+            Padding(
+              padding: const EdgeInsets.only(bottom: 8, top: 16),
+              child: RichText(
+                text: TextSpan(
+                  children: [
+                    TextSpan(
+                      text: widget.isLogin
+                          ? S.of(context).cake_phone_terms_conditions_first_section_login
+                          : S.of(context).cake_phone_terms_conditions_first_section_signup,
+                    ),
+                    TextSpan(
+                      text: " ${S.of(context).settings_terms_and_conditions}",
+                      style: TextStyle(
+                        color: Theme.of(context).accentTextTheme.display1.color,
+                        fontWeight: FontWeight.w600,
+                      ),
+                    ),
+                    TextSpan(
+                      text: " ${S.of(context).and} ",
+                    ),
+                    TextSpan(
+                      text: "${S.of(context).privacy_policy} ",
+                      style: TextStyle(
+                        color: Theme.of(context).accentTextTheme.display1.color,
+                        fontWeight: FontWeight.w600,
+                      ),
+                    ),
+                    TextSpan(
+                      text: S.of(context).cake_phone_terms_conditions_second_section,
+                    ),
+                  ],
+                  style: TextStyle(
+                    fontSize: 12,
+                    color: Theme.of(context).accentTextTheme.subhead.color,
+                  ),
+                ),
+                textAlign: TextAlign.center,
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}
diff --git a/lib/src/screens/cake_phone/cake_phone_welcome_page.dart b/lib/src/screens/cake_phone/cake_phone_welcome_page.dart
new file mode 100644
index 000000000..474b634fb
--- /dev/null
+++ b/lib/src/screens/cake_phone/cake_phone_welcome_page.dart
@@ -0,0 +1,92 @@
+import 'package:cake_wallet/routes.dart';
+import 'package:flutter/material.dart';
+import 'package:flutter/cupertino.dart';
+import 'package:cake_wallet/generated/i18n.dart';
+import 'package:cake_wallet/src/widgets/primary_button.dart';
+import 'package:cake_wallet/src/screens/base_page.dart';
+import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
+
+class CakePhoneWelcomePage extends BasePage {
+  CakePhoneWelcomePage();
+
+  @override
+  Widget body(BuildContext context) => CakePhoneWelcomeBody();
+
+  @override
+  Widget middle(BuildContext context) {
+    return Text(
+      S.of(context).welcome_to_cake_phone,
+      style: TextStyle(
+          fontSize: 22,
+          fontWeight: FontWeight.w600,
+          fontFamily: 'Lato',
+          color: titleColor ??
+              Theme.of(context).primaryTextTheme.title.color),
+    );
+  }
+}
+
+class CakePhoneWelcomeBody extends StatefulWidget {
+  CakePhoneWelcomeBody();
+
+  @override
+  CakePhoneWelcomeBodyState createState() => CakePhoneWelcomeBodyState();
+}
+
+class CakePhoneWelcomeBodyState extends State<CakePhoneWelcomeBody> {
+  @override
+  Widget build(BuildContext context) {
+    return Container(
+      padding: EdgeInsets.only(top: 16),
+      child: ScrollableWithBottomSection(
+        contentPadding: EdgeInsets.fromLTRB(24, 100, 24, 20),
+        content: Text(
+          '''Cake Phone allows you to purchase virtual phone numbers with digital assets!
+
+Only an email is required.''',
+          style: TextStyle(
+            fontSize: 16,
+            color: Theme.of(context).primaryTextTheme.title.color,
+            fontFamily: 'Lato',
+          ),
+        ),
+        bottomSectionPadding: EdgeInsets.only(bottom: 24, right: 24, left: 24),
+        bottomSection: Column(
+          children: <Widget>[
+            PrimaryButton(
+              onPressed: () {
+                Navigator.pushNamed(context, Routes.cakePhoneAuth);
+              },
+              text: S.of(context).create_account,
+              color: Theme.of(context).accentTextTheme.body2.color,
+              textColor: Colors.white,
+            ),
+            Padding(
+              padding: const EdgeInsets.only(bottom: 8, top: 16),
+              child: Text(
+                S.of(context).already_have_account,
+                style: TextStyle(
+                  color: Theme.of(context).primaryTextTheme.title.color,
+                  fontWeight: FontWeight.w500,
+                ),
+              ),
+            ),
+            InkWell(
+              onTap: () {
+                Navigator.pushNamed(context, Routes.cakePhoneAuth, arguments: true);
+              },
+              child: Text(
+                S.of(context).login,
+                style: TextStyle(
+                  color: Theme.of(context).accentTextTheme.display1.color,
+                  fontSize: 16,
+                  fontWeight: FontWeight.w900,
+                ),
+              ),
+            ),
+          ],
+        ),
+      ),
+    );
+  }
+}
diff --git a/res/values/strings_en.arb b/res/values/strings_en.arb
index 639c97c97..f5f4bc8cf 100644
--- a/res/values/strings_en.arb
+++ b/res/values/strings_en.arb
@@ -534,5 +534,15 @@
   "search_currency": "Search currency",
   "new_template" : "New Template",
   "electrum_address_disclaimer": "We generate new addresses each time you use one, but previous addresses continue to work",
-  "wallet_name_exists": "Wallet with that name has already existed"
+  "wallet_name_exists": "Wallet with that name has already existed",
+  "welcome_to_cake_phone": "Welcome to Cake Phone",
+  "create_account": "Create Account",
+  "signup": "Sign up",
+  "already_have_account": "Already have an account?",
+  "cake_phone_terms_conditions_first_section_signup": "By creating account you agree to the",
+  "cake_phone_terms_conditions_first_section_login": "You agree to the",
+  "cake_phone_terms_conditions_second_section": "of Cake Phone, which indicates you will receive all account notices and information electronically to the email address provided",
+  "privacy_policy": "Privacy Policy",
+  "and": "and",
+  "emailAddress": "Email Address"
 }