diff --git a/lib/main.dart b/lib/main.dart index 3f6c3ff..94a24e8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -1,15 +1,12 @@ import 'package:flutter/material.dart'; import 'views/radio.dart'; -import 'controller/ws.dart'; void main() { - LiveFeeder f = LiveFeeder(); - f.init(); - runApp(const MyApp()); + runApp(const CallsApp()); } -class MyApp extends StatelessWidget { - const MyApp({super.key}); +class CallsApp extends StatelessWidget { + const CallsApp({super.key}); @override Widget build(BuildContext context) { diff --git a/lib/views/login.dart b/lib/views/login.dart new file mode 100644 index 0000000..88d0665 --- /dev/null +++ b/lib/views/login.dart @@ -0,0 +1,71 @@ +import 'package:flutter/material.dart'; + +class Login extends StatefulWidget { + const Login({super.key, required this.title}); + + final String title; + + @override + State createState() => _LoginState(); +} + +class _LoginState extends State { + final _formKey = GlobalKey(); + TextEditingController userController = TextEditingController(); + TextEditingController passwordController = TextEditingController(); + + @override + Widget build(BuildContext context) { + return Scaffold( + body: Form( + key: _formKey, + child: Padding( + padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 16), + child: Column(children: [ + TextFormField( + controller: userController, + decoration: const InputDecoration( + border: OutlineInputBorder(), labelText: "Username"), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your username.'; + } + return null; + }, + ), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 8, vertical: 16), + child: TextFormField( + controller: passwordController, + obscureText: true, + decoration: const InputDecoration( + border: OutlineInputBorder(), labelText: "Password"), + validator: (value) { + if (value == null || value.isEmpty) { + return 'Please enter your password'; + } + return null; + }, + )), + Padding( + padding: + const EdgeInsets.symmetric(horizontal: 8, vertical: 16.0), + child: Center( + child: ElevatedButton( + onPressed: () { + if (_formKey.currentState!.validate()) { + // TODO do login here + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar(content: Text('Please login.')), + ); + } + }, + child: const Text('Login'), + ), + )), + ])), + )); + } +} diff --git a/lib/views/radio.dart b/lib/views/radio.dart index 40416ef..d69dbcb 100644 --- a/lib/views/radio.dart +++ b/lib/views/radio.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import '../../views/lcd.dart'; import '../../views/keypad.dart'; +import '../controller/ws.dart'; class MainRadio extends StatefulWidget { const MainRadio({super.key, required this.title}); @@ -12,6 +13,7 @@ class MainRadio extends StatefulWidget { } class _MainRadioState extends State { + LiveFeeder f = LiveFeeder(); @override Widget build(BuildContext context) { return const Scaffold( diff --git a/test/widget_test.dart b/test/widget_test.dart index 44d58b6..16287a1 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -13,7 +13,7 @@ import 'package:calls/main.dart'; void main() { testWidgets('Counter increments smoke test', (WidgetTester tester) async { // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); + await tester.pumpWidget(const CallsApp()); // Verify that our counter starts at 0. expect(find.text('0'), findsOneWidget);