From aaaada1b23eb89ab10d3e652ba7ce6ba1c391a7e Mon Sep 17 00:00:00 2001 From: Specoolazius Date: Mon, 18 Oct 2021 15:01:12 +0200 Subject: [PATCH] created homescreen with password input --- lib/login/loginscreen.dart | 42 ++++++++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/lib/login/loginscreen.dart b/lib/login/loginscreen.dart index 30d57f5..a6a36cb 100644 --- a/lib/login/loginscreen.dart +++ b/lib/login/loginscreen.dart @@ -1,12 +1,21 @@ import 'package:flutter/material.dart'; -import 'package:flutter_noise/main.dart'; -void main() => runApp(const LoginPage()); +void main() => runApp(MyApp()); // ToDo: remove when done: currently only for testing purposes -class LoginPage extends StatefulWidget { - const LoginPage({Key? key}) : super(key: key); +class MyApp extends StatelessWidget { + @override + Widget build(BuildContext context) { + return MaterialApp( + debugShowCheckedModeBanner: false, + title: 'Noise!', + home: LoginPage(), + ); + } +} + +class LoginPage extends StatefulWidget { @override _LoginPageState createState() => _LoginPageState(); } @@ -18,8 +27,29 @@ class _LoginPageState extends State { Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: const Text('Welcome')), - body: Center( - + // https://www.kindacode.com/article/flutter-show-hide-password-in-textfield-textformfield/ + // https://www.kindacode.com/article/flutter-filteringtextinputformatter/ + body: Padding( + padding: const EdgeInsets.all(10), + child: Center( + child: TextField( + obscureText: _isPasswordObscure, + decoration: InputDecoration( + hintText: 'Password', + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(10) + ), + suffixIcon: IconButton( + icon: Icon(_isPasswordObscure + ? Icons.visibility + : Icons.visibility_off), + onPressed: () { + setState(() { + _isPasswordObscure = !_isPasswordObscure; + }); + }, + ))), + ), )); } }