From cb94977be9207640b2db7eb04f0ab050a40365d9 Mon Sep 17 00:00:00 2001
From: Maximilian Betz <Maximilian.Betz@awi.de>
Date: Tue, 15 Mar 2022 13:28:39 +0100
Subject: [PATCH] remove obsolete login widget

---
 lib/login.dart | 152 -------------------------------------------------
 lib/main.dart  |   2 -
 2 files changed, 154 deletions(-)
 delete mode 100644 lib/login.dart

diff --git a/lib/login.dart b/lib/login.dart
deleted file mode 100644
index 0f52d95..0000000
--- a/lib/login.dart
+++ /dev/null
@@ -1,152 +0,0 @@
-import 'package:flutter/cupertino.dart';
-import 'package:flutter/material.dart';
-import 'datamodel.dart';
-import 'dart:convert';
-import 'package:http/http.dart' as http;
-
-Future<int> login() async {
-  // Get Access to local configuration store. Token must be stored there!
-  ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
-
-  String url = 'https://sandbox.sensor.awi.de/rest/sensors/contacts/login';
-  debugPrint("Start login to : " + url);
-
-  Map<String, dynamic> body = {'username': configuration.loginInformation.mail, 'authPassword': configuration.loginInformation.password};
-  String encodedBody = body.keys.map((key) => "$key=${body[key]}").join("&");
-  debugPrint(encodedBody);
-
-  final response = await http.post(Uri.parse(url),
-      body: encodedBody,
-      headers: {
-        'Accept' : 'application/json',
-        'Content-Type' : 'application/x-www-form-urlencoded'
-      },
-      encoding: Encoding.getByName("utf-8")
-      );
-
-  if (response.statusCode == 200) {
-    debugPrint('Login success');
-
-    debugPrint(response.body.toString());
-    debugPrint(response.headers.toString());
-    debugPrint(response.headers['set-cookie']);
-
-  } else {
-    debugPrint('Header: ' + response.headers.toString());
-    debugPrint('Body: ' + response.body.toString());
-    debugPrint('StatusCode: ' + response.statusCode.toString());
-    throw Exception('Failed to login');
-  }
-
-  return 0;
-}
-
-
-
-class LoginPage extends StatefulWidget{
-  static String tag = 'login-page';
-
-  const LoginPage({Key? key}) : super(key: key);
-  @override
-  _LoginPageState createState() => _LoginPageState();
-}
-
-class _LoginPageState extends State<LoginPage> {
-  @override
-  Widget build(BuildContext context){
-
-    final ConfigurationStoreInstance configuration = ConfigurationStoreInstance();
-
-    var logo = Hero(
-        tag: 'blabla',
-        child: CircleAvatar(
-          backgroundColor: Colors.transparent,
-          radius: 48.0,
-          child: Image.asset('assets/awi_logo.png'),
-        )
-    );
-
-    final email = TextFormField(
-        keyboardType: TextInputType.emailAddress,
-        autofocus: false,
-        initialValue: configuration.loginInformation.mail,
-        decoration: InputDecoration(
-            hintText: 'sensor e-mail address',
-            contentPadding: const EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
-            border: OutlineInputBorder(
-                borderRadius: BorderRadius.circular(32.0)
-            )
-        ),
-      onChanged: (value) {
-        configuration.loginInformation.mail = value;
-      },
-    );
-
-    final password = TextFormField(
-      autofocus: false,
-      initialValue: configuration.loginInformation.password,
-      decoration: InputDecoration(
-          hintText: 'sensor password',
-          contentPadding: const EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
-          border: OutlineInputBorder(
-              borderRadius: BorderRadius.circular(32.0)
-          )
-      ),
-      onChanged: (value){
-        configuration.loginInformation.password = value;
-      },
-    );
-
-
-    final loginButton = Padding(
-      padding: const EdgeInsets.symmetric(vertical: 16.0),
-      child: Material(
-        borderRadius: BorderRadius.circular(30.0),
-        shadowColor: Colors.lightBlueAccent.shade100,
-        elevation: 5.0,
-        child: MaterialButton(
-          minWidth: 200.0,
-          height: 42.0,
-          onPressed: (){
-            login();
-            //Navigator.pop(context);  // Go back to previous widget
-
-            //Return to previous widget if successfully logged in. Store x-auth-token.
-            //Display login error if login not possible.
-          },
-          color: Colors.lightBlueAccent,
-          child: const Text('Log In', style: TextStyle(color: Colors.white)),
-        ),
-      ),
-    );
-
-    final forgotLabel = TextButton(
-      onPressed: () {  },
-      child: const Text('Forgot password?',
-        style: TextStyle(color: Colors.black54),
-      ),
-    );
-
-    return Scaffold(
-        backgroundColor: Colors.white,
-        body: Center(
-            child: ListView(
-              shrinkWrap: true,
-              padding: const EdgeInsets.only(left: 24.0, right: 24.0),
-              children: <Widget>[
-                logo,
-                const SizedBox(height: 48.0),
-                email,
-                const SizedBox(height: 8.0),
-                password,
-                const SizedBox(height: 24.0),
-                loginButton,
-                forgotLabel //TODO: launch https://data.awi.de/auth/
-
-
-              ],
-            )
-        )
-    );
-  }
-}
\ No newline at end of file
diff --git a/lib/main.dart b/lib/main.dart
index 14701a6..c15c553 100644
--- a/lib/main.dart
+++ b/lib/main.dart
@@ -6,7 +6,6 @@ import 'addevent.dart';
 import 'viewevents.dart';
 import 'overview.dart';
 import 'configuration.dart';
-import 'login.dart';
 
 void main() {
   
@@ -33,7 +32,6 @@ void main() {
       '/second': (context) => const AddEvent(),
       '/third': (context) => const ViewEvents(),
       '/forth': (context) => const Configuration(),
-      '/fifth': (context) => const LoginPage(),
     },
   ));
 }
-- 
GitLab