From 8ee6749b4748d66c3d5fd713ef627910e02d91bb Mon Sep 17 00:00:00 2001 From: David Date: Fri, 21 Feb 2020 15:36:45 -0500 Subject: [PATCH] add HorizontalNewsFeed widget --- lib/home_widget.dart | 1129 ++++++++++++++++++++++-------------------- 1 file changed, 603 insertions(+), 526 deletions(-) diff --git a/lib/home_widget.dart b/lib/home_widget.dart index 5cdb0fb..f00030e 100644 --- a/lib/home_widget.dart +++ b/lib/home_widget.dart @@ -3,540 +3,617 @@ import 'placeholder_widget.dart'; class Home extends StatefulWidget { @override - _HomeState createState() => _HomeState(); + State createState() => TestState(); } -class _HomeState extends State{ - int _currentIndex = 0; - final List _children = [ - ListView( - scrollDirection: Axis.vertical, - children: [ - Container( - height: 175, - margin: EdgeInsets.symmetric(vertical: 10), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.orange, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.orange, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.orange, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.orange, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.orange, - ), - ), - ], - ), - ), - ), - ], - ), - ), - Container( - height: 175, - margin: EdgeInsets.symmetric(vertical: 10), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.green, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.green, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.green, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.green, - ), - ), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children:[ - ListTile( - leading: FlutterLogo(), - title: Text('Testing Fancy Shit'), - ), - Expanded( - child: Container( - color: Colors.green, - ), - ), - ], - ), - ), - ), - ], - ), - ), - Container( - height: 175, - margin: EdgeInsets.symmetric(vertical: 10), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.purple, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.purple, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.purple, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.purple, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.purple, - ), - ), - Text('Testing'), - ], - ), - ), - ), - ], - ), - ), - Container( - height: 175, - margin: EdgeInsets.symmetric(vertical: 10), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.blue, ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.blue, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.blue, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.blue, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.blue, - ), - ), - Text('Testing'), - ], - ), - ), - ), - ], - ), - ), - Container( - height: 175, - margin: EdgeInsets.symmetric(vertical: 10), - child: ListView( - scrollDirection: Axis.horizontal, - children: [ - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.red, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.red, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.red, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.red, - ), - ), - Text('Testing'), - ], - ), - ), - ), - Container( - width: 325, - margin: EdgeInsets.symmetric(horizontal: 10), - child: Card( - child: Column( - children: [ - Expanded( - child: Container( - color: Colors.red, - ), - ), - Text('Testing'), - ], - ), - ), - ), - ], - ), - ), - - ], - ), - PlaceholderWidget(Colors.orange), - PlaceholderWidget(Colors.blue), - PlaceholderWidget(Colors.red), - PlaceholderWidget(Colors.black38), - ]; - +class TestState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: AppBar( - title: Text('UNCC Athletics App'), - ), - body: Container( - child: _children[_currentIndex] - ), - bottomNavigationBar: BottomNavigationBar( - type: BottomNavigationBarType.fixed, - onTap: onTabTapped, - currentIndex: _currentIndex, - items: [ - BottomNavigationBarItem( - icon: new Icon(Icons.home), - title: new Text("Home"), - ), - BottomNavigationBarItem( - icon: new Icon(Icons.calendar_today), - title: new Text("Schedule") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.table_chart), - title: new Text("Scores") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.assessment), - title: new Text("Standings") - ), - BottomNavigationBarItem( - icon: new Icon(Icons.more_horiz), - title: new Text("More") - ) + body: ListView( + children: [ + HorizontalNewsFeed(title: Text("Basketball")), + HorizontalNewsFeed(title: Text("Soccer")), + HorizontalNewsFeed(title: Text("Football")), ], ), + appBar: AppBar( + title: Text("u mum gay"), + ), ); } +} - void onTabTapped(int index) { - setState(() { - _currentIndex = index; - }); +class HorizontalNewsFeed extends StatelessWidget { + const HorizontalNewsFeed({ + Key key, + @required this.title, + }) : super(key: key); + + final Widget title; + + @override + Widget build(BuildContext context) { + var width = MediaQuery.of(context).size.width / 2.25; + var height = width * .6; + + return Column( + children: [ + Divider(), + ListTile( + title: title, + trailing: IconButton( + icon: Icon(Icons.navigate_next), + onPressed: () { + showDialog( + context: context, + child: Center( + child: Card( + elevation: 10, + child: Image.network( + "https://discordemoji.com/assets/emoji/ThinkNoose.png", + width: 100, + height: 100, + ), + ), + ), + ); + }, + ), + ), + Container( + height: height, + child: ListView.builder( + scrollDirection: Axis.horizontal, + itemCount: 6, + itemBuilder: (ictx, iidx) { + return NewsCard(height: height, width: width); + }, + ), + ), + ], + ); } -} \ No newline at end of file +} + +class NewsCard extends StatelessWidget { + const NewsCard({ + Key key, + @required this.height, + @required this.width, + }) : super(key: key); + + final double height; + final double width; + + @override + Widget build(BuildContext context) { + return Container( + height: height, + width: width, + child: Card( + child: ListTile( + title: Text("no u"), + ), + ), + ); + } +} + +//class _HomeState extends State{ +// int _currentIndex = 0; +// final List _children = [ +// ListView( +// scrollDirection: Axis.vertical, +// children: [ +// Container( +// height: 175, +// margin: EdgeInsets.symmetric(vertical: 10), +// child: ListView( +// scrollDirection: Axis.horizontal, +// children: [ +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.orange, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.orange, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.orange, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.orange, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.orange, +// ), +// ), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// Container( +// height: 175, +// margin: EdgeInsets.symmetric(vertical: 10), +// child: ListView( +// scrollDirection: Axis.horizontal, +// children: [ +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.green, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.green, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.green, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.green, +// ), +// ), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children:[ +// ListTile( +// leading: FlutterLogo(), +// title: Text('Testing Fancy Shit'), +// ), +// Expanded( +// child: Container( +// color: Colors.green, +// ), +// ), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// Container( +// height: 175, +// margin: EdgeInsets.symmetric(vertical: 10), +// child: ListView( +// scrollDirection: Axis.horizontal, +// children: [ +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.purple, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.purple, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.purple, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.purple, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.purple, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// Container( +// height: 175, +// margin: EdgeInsets.symmetric(vertical: 10), +// child: ListView( +// scrollDirection: Axis.horizontal, +// children: [ +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.blue, ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.blue, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.blue, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.blue, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.blue, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// Container( +// height: 175, +// margin: EdgeInsets.symmetric(vertical: 10), +// child: ListView( +// scrollDirection: Axis.horizontal, +// children: [ +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.red, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.red, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.red, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.red, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// Container( +// width: 325, +// margin: EdgeInsets.symmetric(horizontal: 10), +// child: Card( +// child: Column( +// children: [ +// Expanded( +// child: Container( +// color: Colors.red, +// ), +// ), +// Text('Testing'), +// ], +// ), +// ), +// ), +// ], +// ), +// ), +// +// ], +// ), +// PlaceholderWidget(Colors.orange), +// PlaceholderWidget(Colors.blue), +// PlaceholderWidget(Colors.red), +// PlaceholderWidget(Colors.black38), +// ]; +// +// @override +// Widget build(BuildContext context) { +// return Scaffold( +// appBar: AppBar( +// title: Text('UNCC Athletics App'), +// ), +// body: Container(child: _children[_currentIndex]), +// bottomNavigationBar: BottomNavigationBar( +// type: BottomNavigationBarType.fixed, +// items: [ +// BottomNavigationBarItem( +// icon: new Icon(Icons.home), +// title: new Text("Home"), +// ), +// BottomNavigationBarItem( +// icon: new Icon(Icons.calendar_today), +// title: new Text("Schedule")), +// BottomNavigationBarItem( +// icon: new Icon(Icons.table_chart), title: new Text("Scores")), +// BottomNavigationBarItem( +// icon: new Icon(Icons.assessment), title: new Text("Standings")), +// BottomNavigationBarItem( +// icon: new Icon(Icons.more_horiz), title: new Text("More")) +// ], +// ), +// ); +// } +//}