From e86b95ab46ad984f62f5966a93d6f71d574c8175 Mon Sep 17 00:00:00 2001 From: Carlos Lopez-Rosario Date: Sat, 8 Feb 2020 19:05:33 -0500 Subject: [PATCH] Creating the Dropdown sport selector, functionality yet to come --- lib/drop_down_widget.dart | 38 ++++++++++++++++++++++++++++++++++++++ lib/home_widget.dart | 10 +++++++++- lib/main.dart | 1 - 3 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 lib/drop_down_widget.dart diff --git a/lib/drop_down_widget.dart b/lib/drop_down_widget.dart new file mode 100644 index 0000000..78b293d --- /dev/null +++ b/lib/drop_down_widget.dart @@ -0,0 +1,38 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter/widgets.dart'; + +class DropDownWidget extends StatefulWidget { + @override + _DropDownWidget createState() => _DropDownWidget(); +} + +class _DropDownWidget extends State{ + String curSport = "Men's Basketball"; + + @override + Widget build(BuildContext context) { + return DropdownButton( + value: curSport, + icon: Icon(Icons.arrow_drop_down), + iconSize: 24, + style: TextStyle(color: Colors.black), + iconEnabledColor: Colors.white, + onChanged: (String newSport) { + setState(() { + curSport = newSport; + }); + }, + items: ["Men's Basketball", "Women's Basketball", "Baseball", "Softball", "FootBall"] + .map>((String value) { + return DropdownMenuItem( + value: value, + child: SizedBox( + width: 100, + child: Text(value), + ), + ); + }).toList(), + ); + } +} \ No newline at end of file diff --git a/lib/home_widget.dart b/lib/home_widget.dart index 22dabbb..cb41b75 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -1,5 +1,6 @@ import 'package:flutter/material.dart'; import 'placeholder_widget.dart'; +import 'drop_down_widget.dart'; class Home extends StatefulWidget { @override @@ -8,6 +9,8 @@ class Home extends StatefulWidget { class _HomeState extends State{ int _currentIndex = 0; + var curSport = ''; + final List _children = [ PlaceholderWidget(Colors.white), PlaceholderWidget(Colors.orange), @@ -20,7 +23,12 @@ class _HomeState extends State{ Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('UNCC Athletics App'), + + //title: Text(appBarTitle), + actions: [ + DropDownWidget(), + ], + backgroundColor: Colors.green, ), body: _children[_currentIndex], bottomNavigationBar: BottomNavigationBar( diff --git a/lib/main.dart b/lib/main.dart index 47d6b1c..aad7acc 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ class App extends StatelessWidget{ Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, - title: 'UNCC Athletics', home: Home(), ); }