Twitter - proof of concept - needs api fleshed out. has place holder data
This commit is contained in:
@@ -3,20 +3,37 @@ import 'package:flutter/material.dart';
|
||||
import '../twitter_assets/tweet.dart';
|
||||
|
||||
class TwitterFeed extends StatelessWidget{
|
||||
final feed = TwitterFeedCreation();
|
||||
List<Tweet> fuck = [];
|
||||
final test = new Tweet(1, "We'll get through this together, Niner Nation. #WeAreAllNiners", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test2 = new Tweet(2, "Let's test your UNC Charlotte knowledge...do you know why we became the 49ers? Here's the full history on the pioneering spirit that shaped our trajectory http://bit.ly/UNCC-1949", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test3 = new Tweet(3, "Niner Nation means uplifting each other. This 4/9 Day, let's show our students why #WeAreAllNiners by supporting the Student Emergency Relief Fund ️ http://bit.ly/UNCC-SER", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test4 = new Tweet(4, "Niner Nation: Chancellor Dubois shares that UNC Charlotte will be able to apply our established parking refund procedures with special considerations for the impact of COVID-19.", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test5 = new Tweet(5, "4/9 Day is just for us, Niner Nation. From wherever you are, you're family #WeAreAllNiners", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test6= new Tweet(6, "Niner Nation, #49erAlumni Gene Johnson ’73 is getting us excited for 4/9 Day tomorrow! Put on your Niner gear, call your friends and let’s celebrate together virtually \n We’re all in this together! ", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
final test7 = new Tweet(7, "From virtual events to one-on-one sessions with counselors, it's easy to stay connected with @UNCCAdmissions", "@unccharlotte", "https://pbs.twimg.com/profile_images/1175214096280629249/QC79Xju2_400x400.jpg", "test");
|
||||
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
fuck.add(test);
|
||||
fuck.add(test2);
|
||||
fuck.add(test3);
|
||||
fuck.add(test4);
|
||||
fuck.add(test5);
|
||||
fuck.add(test6);
|
||||
fuck.add(test7);
|
||||
|
||||
return StatefulBuilder(
|
||||
builder: (context, StateSetter setState) => Scaffold(
|
||||
appBar: AppBar(
|
||||
centerTitle: false,
|
||||
title: Text("49ers"),
|
||||
title: Text("49ers Tweets"),
|
||||
backgroundColor: Colors.green,
|
||||
),
|
||||
body: Container(
|
||||
color: Colors.black12,
|
||||
child: VerticalTwitterFeed(twitterFeed: feed),
|
||||
child:
|
||||
VerticalTwitterFeed(twitterFeed: fuck),
|
||||
),
|
||||
drawer: Drawer(
|
||||
child: ListView(
|
||||
|
||||
@@ -8,14 +8,14 @@ class Tweet {
|
||||
final String url;
|
||||
|
||||
Tweet(
|
||||
this.id, {
|
||||
this.id,
|
||||
this.text,
|
||||
this.userName,
|
||||
this.userImgUrl,
|
||||
this.url,
|
||||
});
|
||||
);
|
||||
|
||||
factory Tweet.fromJson(Map<String, dynamic> json) {
|
||||
/*factory Tweet.fromJson(Map<String, dynamic> json) {
|
||||
return Tweet(
|
||||
json['id_str'],
|
||||
text: json['text'],
|
||||
@@ -24,6 +24,11 @@ class Tweet {
|
||||
url: json['urls']['expanded_url'],
|
||||
);
|
||||
}
|
||||
Commenting out till we figure out the API
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
class TwitterCard extends StatelessWidget{
|
||||
@@ -38,14 +43,25 @@ class TwitterCard extends StatelessWidget{
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Card(
|
||||
child: ListTile(
|
||||
leading: SizedBox(
|
||||
width: 75,
|
||||
height: 75,
|
||||
child: Image.network('${tweet.userImgUrl}'),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0),
|
||||
child: ListTile(
|
||||
leading: SizedBox(
|
||||
height: 125,
|
||||
width: 75,
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
shape: BoxShape.circle,
|
||||
image: DecorationImage(
|
||||
fit: BoxFit.fill,
|
||||
image: NetworkImage('${tweet.userImgUrl}'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
title: Text('${tweet.userName}'),
|
||||
subtitle: Text('${tweet.text}'),
|
||||
),
|
||||
title: Text('${tweet.userName}'),
|
||||
subtitle: Text('${tweet.text}'),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -18,20 +18,20 @@ class TwitterFeedCreation {
|
||||
http.Response response = await http.get('https://api.twitter.com/oauth2/token',);
|
||||
}
|
||||
|
||||
Future<List<Tweet>> getPage({int size = 10}) async {
|
||||
/*Future<List<Tweet>> getPage({int size = 10}) async {
|
||||
var url = '$twitterBase/tweets.json?q=from%3ACharlotteFTBL&result_type=mixed&count=$size';
|
||||
http.Response response = await http.get(url,
|
||||
headers: <String, String> {'authorization': apiKey,}
|
||||
);
|
||||
Iterable tweets = json.decode(response.body);
|
||||
return tweets.map((e) => Tweet.fromJson(e)).toList();
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
|
||||
class VerticalTwitterFeed extends StatelessWidget{
|
||||
|
||||
final TwitterFeedCreation twitterFeed;
|
||||
final List<Tweet> twitterFeed;
|
||||
|
||||
const VerticalTwitterFeed({
|
||||
Key key,
|
||||
@@ -40,7 +40,20 @@ class VerticalTwitterFeed extends StatelessWidget{
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return Container(
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.vertical,
|
||||
itemCount: twitterFeed.length,
|
||||
itemBuilder: (ctx, idx){
|
||||
return TwitterCard(
|
||||
tweet: twitterFeed[idx],
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
/* return Container(
|
||||
child: FutureBuilder(
|
||||
future: twitterFeed.getPage(),
|
||||
builder: (ctx, snapshot){
|
||||
@@ -60,6 +73,6 @@ class VerticalTwitterFeed extends StatelessWidget{
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
); */
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user