2021-10-18 14:07:03 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
2021-10-18 15:01:12 +02:00
|
|
|
void main() => runApp(MyApp());
|
2021-10-18 14:07:03 +02:00
|
|
|
|
|
|
|
// ToDo: remove when done: currently only for testing purposes
|
|
|
|
|
2021-10-18 15:01:12 +02:00
|
|
|
class MyApp extends StatelessWidget {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return MaterialApp(
|
|
|
|
debugShowCheckedModeBanner: false,
|
|
|
|
title: 'Noise!',
|
|
|
|
home: LoginPage(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LoginPage extends StatefulWidget {
|
2021-10-18 14:07:03 +02:00
|
|
|
@override
|
|
|
|
_LoginPageState createState() => _LoginPageState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _LoginPageState extends State<LoginPage> {
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Scaffold(
|
2021-11-15 13:44:33 +01:00
|
|
|
appBar: AppBar(title: const Text('Welcome')),
|
|
|
|
// https://www.kindacode.com/article/flutter-show-hide-password-in-textfield-textformfield/
|
|
|
|
// https://www.kindacode.com/article/flutter-filteringtextinputformatter/
|
|
|
|
body: Center(
|
|
|
|
child: new ListView(
|
|
|
|
shrinkWrap: true,
|
|
|
|
padding: const EdgeInsets.all(20.0),
|
|
|
|
children: [
|
|
|
|
new UsernameField(),
|
|
|
|
new PasswordField(),
|
2021-11-15 13:26:13 +01:00
|
|
|
],
|
2021-11-15 13:44:33 +01:00
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
2021-10-18 14:07:03 +02:00
|
|
|
}
|
|
|
|
}
|
2021-11-15 13:26:13 +01:00
|
|
|
|
|
|
|
class UsernameField extends StatelessWidget {
|
|
|
|
const UsernameField({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Padding(
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
child: Center(
|
|
|
|
child: TextField(
|
|
|
|
decoration: InputDecoration(
|
|
|
|
hintText: 'Username',
|
|
|
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(10)),
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2021-11-15 13:44:33 +01:00
|
|
|
|
|
|
|
class PasswordField extends StatefulWidget {
|
|
|
|
const PasswordField({Key? key}) : super(key: key);
|
|
|
|
|
|
|
|
@override
|
|
|
|
_PasswordFieldState createState() => _PasswordFieldState();
|
|
|
|
}
|
|
|
|
|
|
|
|
class _PasswordFieldState extends State<PasswordField> {
|
|
|
|
bool _isPasswordObscure = true;
|
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return 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;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
))),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|