From faa39272435b0a42292f8327dd84c8520f9af487 Mon Sep 17 00:00:00 2001 From: kiwiidb Date: Fri, 24 Mar 2023 10:59:07 +0100 Subject: [PATCH] login rework --- lib/views/auth/login.dart | 2 + lib/views/login_choice.dart | 121 +++++++++++++++++++----------------- 2 files changed, 67 insertions(+), 56 deletions(-) diff --git a/lib/views/auth/login.dart b/lib/views/auth/login.dart index 4e7dbd1..bfb52c9 100644 --- a/lib/views/auth/login.dart +++ b/lib/views/auth/login.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; +import 'package:nygma/views/index_or_login.dart'; import '../../components/buttons/gradient_button.dart'; import '../../components/labeled_text_form_field.dart'; @@ -42,6 +43,7 @@ class LoginPage extends StatelessWidget { onPressed: () { authController.loginNsec( authController.privkeyController.text); + Get.offAll(IndexOrLogin()); }, text: "continue".tr, ), diff --git a/lib/views/login_choice.dart b/lib/views/login_choice.dart index 2c0401b..f4a95c6 100644 --- a/lib/views/login_choice.dart +++ b/lib/views/login_choice.dart @@ -1,81 +1,90 @@ import 'package:flutter/material.dart'; import 'package:get/get.dart'; import 'package:nygma/app_theme.dart'; +import 'package:nygma/views/auth/login.dart'; +import 'package:nygma/views/index_page.dart'; import 'package:nygma/views/recover_page.dart'; import '../components/buttons/gradient_button.dart'; import '../constants/colors.dart'; +import '../controllers/auth_controller.dart'; import 'index_or_login.dart'; class LoginChoicePage extends StatelessWidget { - const LoginChoicePage({Key? key}) : super(key: key); + final AuthController authController = Get.put(AuthController()); + LoginChoicePage({Key? key}) : super(key: key); @override Widget build(BuildContext context) { - return Scaffold( - appBar: AppBar( - title: Row(children: [ - ClipRRect( - borderRadius: BorderRadius.circular(25), - child: Image.asset( - 'images/icon.png', - height: 50, + return GetX(builder: (controller) { + if (controller.pubkey.value != "") { + return IndexPage(); + } + return Scaffold( + appBar: AppBar( + title: Row(children: [ + ClipRRect( + borderRadius: BorderRadius.circular(25), + child: Image.asset( + 'images/icon.png', + height: 50, + ), ), - ), - const SizedBox( - width: 10, - ), - const Text( - "Nygma", - style: TextStyle(fontSize: 20), - ) - ]), - actions: []), - body: DecoratedBox( - decoration: const BoxDecoration(gradient: kBgGradient), - child: Center( - child: Padding( - padding: const EdgeInsets.symmetric(horizontal: 20.0), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - SizedBox( - width: double.infinity, - height: 60, - child: GradientButton( - onPressed: () { - Get.offAll(IndexOrLogin()); - }, - child: const Text( - 'Login', - style: TextStyle( - fontSize: 24, + const SizedBox( + width: 10, + ), + const Text( + "Nygma", + style: TextStyle(fontSize: 20), + ) + ]), + actions: []), + body: DecoratedBox( + decoration: const BoxDecoration(gradient: kBgGradient), + child: Center( + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 20.0), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + SizedBox( + width: double.infinity, + height: 60, + child: GradientButton( + onPressed: () { + Get.to(LoginPage()); + }, + child: const Text( + 'Login', + style: TextStyle( + fontSize: 24, + ), ), ), ), - ), - const SizedBox(height: 20), - SizedBox( - width: double.infinity, - height: 60, - child: GradientButton( - onPressed: () { - Get.to(RecoverPage()); - }, - child: const Text( - 'Recover', - style: TextStyle( - fontSize: 24, - color: Colors.white, + const SizedBox(height: 20), + SizedBox( + width: double.infinity, + height: 60, + child: GradientButton( + onPressed: () { + Get.to(RecoverPage()); + }, + child: const Text( + 'Recover', + style: TextStyle( + fontSize: 24, + color: Colors.white, + ), ), ), ), - ), - ], + ], + ), ), ), ), - ), - ); + ); + }); } }