From 9588aa5b55dd73fc0ce05fba47519f90d4090465 Mon Sep 17 00:00:00 2001 From: Ryan Radloff Date: Thu, 3 Feb 2022 16:46:51 -0600 Subject: [PATCH] Remove login page and service calls --- compulse/lib/login.dart | 86 ---------------------------------- compulse/lib/main.dart | 27 ++--------- compulse/lib/serviceCalls.dart | 60 ------------------------ 3 files changed, 3 insertions(+), 170 deletions(-) delete mode 100644 compulse/lib/login.dart delete mode 100644 compulse/lib/serviceCalls.dart diff --git a/compulse/lib/login.dart b/compulse/lib/login.dart deleted file mode 100644 index 7ecbf17..0000000 --- a/compulse/lib/login.dart +++ /dev/null @@ -1,86 +0,0 @@ -import 'package:flutter/material.dart'; - -const PRIMARY_COLOR = 0xFF2F3B48; -const SECONDARY_COLOR = 0xFFFDF5EB; -const BUTTON_GREEN = 0xFF00C475; - -class LoginRoute extends StatelessWidget { - LoginRoute({Key? key}) : super(key: key); - - final TextEditingController usernameController = TextEditingController(); - // final TextEditingController passwordController = TextEditingController(); - final _formKey = GlobalKey(); - - void _sendUsernameBack(BuildContext context, bool isLogin) { - Navigator.pop(context, [usernameController.text, isLogin]); - } - - String? isNotEmpty(value) { - if (value.isEmpty) { - return 'Please enter a value'; - } - return null; - } - - @override - Widget build(BuildContext context) { - return Scaffold( - backgroundColor: Color(PRIMARY_COLOR), - appBar: AppBar( - backgroundColor: Color(PRIMARY_COLOR), - iconTheme: IconThemeData(color: Color(SECONDARY_COLOR)), - title: const Text('Log In', style: TextStyle(color: Color(SECONDARY_COLOR)),), - ), - body: Center( - child: Form( - key: _formKey, - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Container( - width: 300.0, - padding: const EdgeInsets.only(bottom: 10.0), - child: TextFormField( - controller: usernameController, - decoration: const InputDecoration( - fillColor: Color(SECONDARY_COLOR), - filled: true, - enabledBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(BUTTON_GREEN)), - borderRadius: BorderRadius.all(Radius.circular(10)), - ), - focusedBorder: OutlineInputBorder( - borderSide: BorderSide(color: Color(BUTTON_GREEN)), - borderRadius: BorderRadius.all(Radius.circular(10)), - ), - border: OutlineInputBorder( - borderSide: BorderSide(color: Color(BUTTON_GREEN)), - borderRadius: BorderRadius.all(Radius.circular(10)), - ), - hintText: 'Enter your username', - ), - autocorrect: false, - autofocus: true, - validator: isNotEmpty)), - ElevatedButton( - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Color(BUTTON_GREEN))), - onPressed: () { - if (_formKey.currentState!.validate()) { - _sendUsernameBack(context, true); - } - }, - child: const Text("Log In"), - ), - ElevatedButton( - style: ButtonStyle(backgroundColor: MaterialStateProperty.all(Color(BUTTON_GREEN))), - onPressed: () { - if (_formKey.currentState!.validate()) { - _sendUsernameBack(context, false); - } - }, - child: const Text("Sign Up"), - ) - ])), - )); - } -} \ No newline at end of file diff --git a/compulse/lib/main.dart b/compulse/lib/main.dart index 438a2b3..3034af5 100644 --- a/compulse/lib/main.dart +++ b/compulse/lib/main.dart @@ -2,8 +2,6 @@ import 'package:flutter/material.dart'; import 'fileHandler.dart'; import 'statusTile.dart'; import 'newItemPage.dart'; -import 'login.dart'; -import 'serviceCalls.dart'; import 'package:google_fonts/google_fonts.dart'; const PRIMARY_COLOR = 0xFF2F3B48; @@ -47,7 +45,6 @@ class _CheckUpAppState extends State { List s = await _listFuture; s.remove(t); write(s); - postUpdate(username, s); refreshList(); } @@ -55,7 +52,6 @@ class _CheckUpAppState extends State { List s = await _listFuture; s.add(t); write(s); - postUpdate(username, s); refreshList(); } @@ -92,7 +88,9 @@ class _CheckUpAppState extends State { appBar: AppBar( backgroundColor: Color(PRIMARY_COLOR), title: const Image(image: AssetImage('assets/banner.png')), - actions: [TextButton(child: Icon(Icons.person, color: Color(BUTTON_GREEN),), onPressed: () {_login(context);},)], + actions: [TextButton(child: Icon(Icons.settings, color: Color(BUTTON_GREEN),), onPressed: () { + // TODO: Add route to settings page here + },)], ), body: ReorderableListView( children: items, @@ -103,7 +101,6 @@ class _CheckUpAppState extends State { final StatusTile item = items.removeAt(oldIndex); items.insert(newIndex, item); write(items); - postUpdate(username, items); }), floatingActionButton: FloatingActionButton( foregroundColor: Color(SECONDARY_COLOR), @@ -132,24 +129,6 @@ class _CheckUpAppState extends State { }); } - void _login(BuildContext context) async { - final result = await Navigator.push( - context, - MaterialPageRoute( - builder: (context) => LoginRoute(), - ), - ); - username = result[0]; - if (result[1] == false) { - postInsert(result[0], await _listFuture); - } else { - _listFuture = getSelect(result[0], removeItemList); - List s = await _listFuture; - write(s); - refreshList(); - } - } - void _awaitAcess(BuildContext context) async { final result = await Navigator.push( context, diff --git a/compulse/lib/serviceCalls.dart b/compulse/lib/serviceCalls.dart deleted file mode 100644 index 84c4fb9..0000000 --- a/compulse/lib/serviceCalls.dart +++ /dev/null @@ -1,60 +0,0 @@ -import 'dart:convert'; - -import 'package:flutter/material.dart'; -import 'package:http/http.dart' as http; -import 'statusTile.dart'; -import 'dart:convert'; - -void postInsert(String username, List l) { - String data = ""; - for (int i = 0; i < l.length; i++) { - data += json.encode(l[i].str()) + "\n"; - } - http.post( - Uri.parse("https://checkup-cloudsql-api-6fcck7nssq-uc.a.run.app/insert"), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: jsonEncode({'username': username, 'data': data})); -} - -Future> getSelect(String username, Function f) async { - var response = await http.get( - Uri.parse("https://checkup-cloudsql-api-6fcck7nssq-uc.a.run.app/select") - .replace(queryParameters: { - "username": username - })); -print(response.body); - - Map result = Map.from(json.decode(response.body)); - - List list = []; - print(result["Data"]); - - List lines = LineSplitter.split(result["Data"]).toList(); - for (int i = 0; i < lines.length; i++) { - Map line = Map.from(json.decode(lines[i])); - list.add(StatusTile( - taskText: line["taskText"]!, - timeDone: line["timeDone"]!, - isDone: line["isDone"]!.toLowerCase() == 'true', - videoPath: line["videoPath"]!, - key: Key(line["taskText"]!), - delete: f, - )); - } - return list; -} - -void postUpdate(String username, List l) { - String data = ""; - for (int i = 0; i < l.length; i++) { - data += json.encode(l[i].str()) + "\n"; - } - http.post( - Uri.parse("https://checkup-cloudsql-api-6fcck7nssq-uc.a.run.app/update"), - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }, - body: jsonEncode({'username': username, 'data': data})); -}