more info on feed cards

This commit is contained in:
2020-02-21 16:23:17 -05:00
parent e9d8c3b0c1
commit df1db9f523
2 changed files with 76 additions and 77 deletions

View File

@@ -1,5 +1,5 @@
import 'package:flutter/material.dart';
import 'placeholder_widget.dart';
import 'news_feed.dart';
class Home extends StatefulWidget {
@override
@@ -18,6 +18,7 @@ class HomeState extends State<Home> {
HorizontalNewsFeed(title: Text("Basketball")),
HorizontalNewsFeed(title: Text("Soccer")),
HorizontalNewsFeed(title: Text("Football")),
HorizontalNewsFeed(title: Text("Volleyball")),
],
),
bottomNavigationBar: BottomNavigationBar(
@@ -41,79 +42,3 @@ class HomeState extends State<Home> {
);
}
}
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: <Widget>[
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);
},
),
),
],
);
}
}
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"),
),
),
);
}
}

74
lib/news_feed.dart Normal file
View File

@@ -0,0 +1,74 @@
import 'package:flutter/material.dart';
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 / 1.25;
var height = width * .6;
return Column(
children: <Widget>[
Divider(),
ListTile(
title: title,
trailing: IconButton(
icon: Icon(Icons.navigate_next),
onPressed: () {},
),
),
Container(
height: height,
child: ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 6,
itemBuilder: (ictx, iidx) {
return NewsCard(height: height, width: width);
},
),
),
],
);
}
}
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 SizedBox(
height: height,
width: width,
child: Card(
clipBehavior: Clip.antiAlias,
child: Wrap(
verticalDirection: VerticalDirection.up,
children: <Widget>[
ListTile(
title: Text("no u"),
trailing: Icon(Icons.more_horiz),
),
Image.network(
"https://pbs.twimg.com/media/ERFFfZpU4AAJmIy.jpg:small",
fit: BoxFit.fitWidth,
),
],
),
),
);
}
}