From c89b72e6670b3a02242bd9727f0872b674ec17da Mon Sep 17 00:00:00 2001 From: Vishesh Handa Date: Thu, 19 Nov 2020 12:20:22 +0100 Subject: [PATCH] Login: Try actually logging in with gotrue --- lib/screens/login_screen.dart | 66 ++++++++++------------------------- pubspec.lock | 16 +++++++++ pubspec.yaml | 3 ++ 3 files changed, 38 insertions(+), 47 deletions(-) diff --git a/lib/screens/login_screen.dart b/lib/screens/login_screen.dart index 817e9691..d1c48565 100644 --- a/lib/screens/login_screen.dart +++ b/lib/screens/login_screen.dart @@ -33,9 +33,12 @@ import 'package:flutter/material.dart'; +import 'package:gotrue/gotrue.dart'; + import 'package:gitjournal/widgets/scroll_view_without_animation.dart'; -//import 'Widget/bezierContainer.dart'; +const _localDevServer = 'http://192.168.1.130:9999/'; +// const _prodServer = 'https://api.gitjournal.io/auth/'; class LoginPage extends StatefulWidget { LoginPage({Key key, this.title}) : super(key: key); @@ -47,56 +50,18 @@ class LoginPage extends StatefulWidget { } class _LoginPageState extends State { - Widget _backButton() { - return InkWell( - onTap: () { - Navigator.pop(context); - }, - child: Container( - padding: const EdgeInsets.symmetric(horizontal: 10), - child: Row( - children: [ - Container( - child: const Icon(Icons.keyboard_arrow_left, color: Colors.black), - ), - const Text( - 'Back', - style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500), - ) - ], - ), - ), - ); - } + var goTrue = GoTrue(_localDevServer); - Widget _entryField(String title, {bool isPassword = false}) { - return Container( - margin: const EdgeInsets.symmetric(vertical: 10), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - title, - style: const TextStyle(fontWeight: FontWeight.bold, fontSize: 15), - ), - const SizedBox( - height: 10, - ), - TextField( - obscureText: isPassword, - decoration: const InputDecoration( - border: InputBorder.none, - fillColor: Color(0xfff3f3f4), - filled: true, - ), - ) - ], - ), - ); + Future _loginAction() async { + var t = await goTrue.login('handa.vish@gmail.com', 'blah'); + print("Got Token: $t"); + + var user = await goTrue.user(t.accessToken); + print("Got usre: $user"); } Widget _submitButton() { - return Container( + var c = Container( width: MediaQuery.of(context).size.width, padding: const EdgeInsets.symmetric(vertical: 15), alignment: Alignment.center, @@ -120,6 +85,13 @@ class _LoginPageState extends State { style: TextStyle(fontSize: 20, color: Colors.white), ), ); + + return InkWell( + onTap: () { + _loginAction(); + }, + child: c, + ); } Widget _divider() { diff --git a/pubspec.lock b/pubspec.lock index ded59b03..9de00910 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -199,6 +199,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.4.2+4" + dio: + dependency: transitive + description: + name: dio + url: "https://pub.dartlang.org" + source: hosted + version: "3.0.10" dots_indicator: dependency: "direct main" description: @@ -476,6 +483,15 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.1" + gotrue: + dependency: "direct main" + description: + path: "." + ref: HEAD + resolved-ref: "5fea2573f075cd307e8cf0c323487b4685f28a87" + url: "https://github.com/GitJournal/gotrue-dart.git" + source: git + version: "1.0.0" html: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 69ccc986..a2a2c14f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,9 @@ dependencies: email_validator: ^1.0.6 icloud_documents_path: git: https://github.com/GitJournal/icloud_documents_path.git + gotrue: + #path: /Users/vishesh/src/gitjournal/gotrue-dart/ + git: https://github.com/GitJournal/gotrue-dart.git dev_dependencies: flutter_launcher_icons: "^0.7.2"