From 0cfd9592f3ea869c5dfff246a51b29a3cb97c2e0 Mon Sep 17 00:00:00 2001 From: Supermjork Date: Mon, 25 Dec 2023 18:04:25 +0200 Subject: [PATCH] Choosing Line, Colour --- lib/input_data.dart | 90 +++++++++++++++++++++++++++++++++++---------- pubspec.lock | 8 ++++ pubspec.yaml | 1 + 3 files changed, 80 insertions(+), 19 deletions(-) diff --git a/lib/input_data.dart b/lib/input_data.dart index 3e092f7..cd0fa68 100644 --- a/lib/input_data.dart +++ b/lib/input_data.dart @@ -2,9 +2,17 @@ import 'package:flutter/material.dart'; import 'package:witl/fetcher.dart'; import 'package:witl/home_screen.dart'; -class InputData extends StatelessWidget { +class InputData extends StatefulWidget { const InputData({super.key}); + @override + _InputDataState createState() => _InputDataState(); +} + +class _InputDataState extends State { + late String selectedColor = 'Blue'; // Default color + late String selectedLine = '1'; // Default line + @override Widget build(BuildContext context) { return Scaffold( @@ -12,32 +20,76 @@ class InputData extends StatelessWidget { title: const Text("Data Input"), ), body: Column( - mainAxisAlignment: MainAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, children: [ - InkWell( - onTap:() { - Navigator.push( - context, - MaterialPageRoute(builder: (context) => const HomeScreen()) - ); - }, - child: Container( - padding: const EdgeInsets.all(20.0), - child: const Text("To Homescreen") - ), + const Text("Choose Tram Line and Colour"), + const SizedBox(height: 15), + const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text("Line:"), + SizedBox(width: 35), + Text("Colour:"), + SizedBox(width: 25), + ], + ), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DropdownButton( + value: selectedLine, + items: ['1', '2'].map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + onChanged: (String? newLine) { + setState(() { + selectedLine = newLine ?? '1'; // Set a default value if newLine is null + }); + }, + ), + const SizedBox(width: 30), + DropdownButton( + value: selectedColor, + items: ['Blue', 'Yellow'].map((String value) { + return DropdownMenuItem( + value: value, + child: Text(value), + ); + }).toList(), + onChanged: (String? newCol) { + setState(() { + selectedColor = newCol ?? 'Blue'; // Set a default value if newCol is null + }); + }, + ), + ], ), const SizedBox(height: 20), InkWell( - onTap:() { + onTap: () { Navigator.push( context, - MaterialPageRoute(builder: (context) => const FetchAPI()) - ); + MaterialPageRoute(builder: (context) => const HomeScreen()), + ); }, child: Container( - padding: const EdgeInsets.all(20.0), - child: const Text("To Fetch Data") - ), + padding: const EdgeInsets.all(20.0), + child: const Text("To Homescreen")), + ), + const SizedBox(height: 20), + InkWell( + onTap: () { + Navigator.push( + context, + MaterialPageRoute(builder: (context) => const FetchAPI()), + ); + }, + child: Container( + padding: const EdgeInsets.all(20.0), + child: const Text("To Fetch Data")), ), ], ), diff --git a/pubspec.lock b/pubspec.lock index 8e26fe5..538754a 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -75,6 +75,14 @@ packages: description: flutter source: sdk version: "0.0.0" + intl: + dependency: "direct main" + description: + name: intl + sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf + url: "https://pub.dev" + source: hosted + version: "0.19.0" lints: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 3a6fd83..dccd6c1 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -35,6 +35,7 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. cupertino_icons: ^1.0.2 + intl: ^0.19.0 dev_dependencies: flutter_test: