4 Commits

Author SHA1 Message Date
kwainright
f819278368 api kicking my ass :( I tried 3 different attempts for authorization but no luck 2020-05-03 14:54:57 -04:00
kwainright
68c7b5c5b3 api trouble shooting 2020-05-02 21:51:19 -04:00
kwainright
764dda9ea6 Twitter Page - set up with api - Testing to get response from api 2020-04-22 17:28:09 -04:00
kwainright
c874d2d5c3 Twitter Page - set up with api - not sure that I'm getting a response 2020-04-21 18:59:25 -04:00
12 changed files with 212 additions and 280 deletions

View File

@@ -1,90 +0,0 @@
# Uncomment this line to define a global platform for your project
# platform :ios, '9.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}
def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
generated_key_values = {}
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) do |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
generated_key_values[podname] = podpath
else
puts "Invalid plugin specification: #{line}"
end
end
generated_key_values
end
target 'Runner' do
use_frameworks!
use_modular_headers!
# Flutter Pod
copied_flutter_dir = File.join(__dir__, 'Flutter')
copied_framework_path = File.join(copied_flutter_dir, 'Flutter.framework')
copied_podspec_path = File.join(copied_flutter_dir, 'Flutter.podspec')
unless File.exist?(copied_framework_path) && File.exist?(copied_podspec_path)
# Copy Flutter.framework and Flutter.podspec to Flutter/ to have something to link against if the xcode backend script has not run yet.
# That script will copy the correct debug/profile/release version of the framework based on the currently selected Xcode configuration.
# CocoaPods will not embed the framework on pod install (before any build phases can generate) if the dylib does not exist.
generated_xcode_build_settings_path = File.join(copied_flutter_dir, 'Generated.xcconfig')
unless File.exist?(generated_xcode_build_settings_path)
raise "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter pub get is executed first"
end
generated_xcode_build_settings = parse_KV_file(generated_xcode_build_settings_path)
cached_framework_dir = generated_xcode_build_settings['FLUTTER_FRAMEWORK_DIR'];
unless File.exist?(copied_framework_path)
FileUtils.cp_r(File.join(cached_framework_dir, 'Flutter.framework'), copied_flutter_dir)
end
unless File.exist?(copied_podspec_path)
FileUtils.cp(File.join(cached_framework_dir, 'Flutter.podspec'), copied_flutter_dir)
end
end
# Keep pod path relative so it can be checked into Podfile.lock.
pod 'Flutter', :path => 'Flutter'
# Plugin Pods
# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
# referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.each do |name, path|
symlink = File.join('.symlinks', 'plugins', name)
File.symlink(path, symlink)
pod name, :path => File.join(symlink, 'ios')
end
end
# Prevent Cocoapods from embedding a second Flutter framework and causing an error with the new Xcode build system.
install! 'cocoapods', :disable_input_output_paths => true
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end

View File

@@ -1,34 +0,0 @@
PODS:
- Flutter (1.0.0)
- shared_preferences (0.0.1):
- Flutter
- shared_preferences_macos (0.0.1):
- Flutter
- shared_preferences_web (0.0.1):
- Flutter
DEPENDENCIES:
- Flutter (from `Flutter`)
- shared_preferences (from `.symlinks/plugins/shared_preferences/ios`)
- shared_preferences_macos (from `.symlinks/plugins/shared_preferences_macos/ios`)
- shared_preferences_web (from `.symlinks/plugins/shared_preferences_web/ios`)
EXTERNAL SOURCES:
Flutter:
:path: Flutter
shared_preferences:
:path: ".symlinks/plugins/shared_preferences/ios"
shared_preferences_macos:
:path: ".symlinks/plugins/shared_preferences_macos/ios"
shared_preferences_web:
:path: ".symlinks/plugins/shared_preferences_web/ios"
SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
shared_preferences: 430726339841afefe5142b9c1f50cb6bd7793e01
shared_preferences_macos: f3f29b71ccbb56bf40c9dd6396c9acf15e214087
shared_preferences_web: 141cce0c3ed1a1c5bf2a0e44f52d31eeb66e5ea9
PODFILE CHECKSUM: 083258d7f5e80b42ea9bfee905fe93049bc04c64
COCOAPODS: 1.7.5

View File

@@ -3,38 +3,34 @@ import 'package:http/http.dart' as http;
import 'package:table_calendar/table_calendar.dart'; import 'package:table_calendar/table_calendar.dart';
import 'screens/sport_schedule.dart'; import 'screens/sport_schedule.dart';
import 'screens/sport.dart' as globals;
import 'dart:convert'; import 'dart:convert';
class Calendar extends StatefulWidget { class Calendar extends StatefulWidget {
final int sportID;
Calendar(this.sportID);
@override @override
_Calendar createState() => _Calendar(sportID); _Calendar createState() => _Calendar();
} }
List _selectedEvents; //List<sport_schedule> _selectedEvents; //original that makes events work
List _selectedEvents; //Removing the <sport_schedule> allows it to still work. Proceed with caution
DateTime selectedDay; DateTime selectedDay;
Map<DateTime, List<sport_schedule>> _events; Map<DateTime, List<sport_schedule>> _events;
class _Calendar extends State<Calendar> with TickerProviderStateMixin { class _Calendar extends State<Calendar> with TickerProviderStateMixin {
int sportID;
_Calendar(this. sportID);
AnimationController _animationController; AnimationController _animationController;
CalendarController _calController; CalendarController _calController;
int sportID = globals.Sport.sport_ID;
static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80'; static final sportUrl = 'https://charlotte49ers.com/services/adaptive_components.ashx?type=scoreboard&start=0&count=80';
Future<List<sport_schedule>> getEvents() async { Future<List<sport_schedule>> getEvents() async {
var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D'; var url = '$sportUrl&sport_id=$sportID&name=&extra=%7B%7D';
print(url.toString());
http.Response response = await http.get(url); http.Response response = await http.get(url);
Iterable games = json.decode(response.body); Iterable games = json.decode(response.body);
return games.map<sport_schedule>((json) => sport_schedule.fromJson(json)).toList(); return games.map<sport_schedule>((json) => sport_schedule.fromJson(json)).toList();
//return games.map((e) => sport_schedule.fromJson(e)).toList();
} }
Future<Map<DateTime, List<sport_schedule>>> getGames() async { Future<Map<DateTime, List<sport_schedule>>> getGames() async {
@@ -51,8 +47,10 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
var original = mapGrab[sportEvent]; var original = mapGrab[sportEvent];
if (original == null) { if (original == null) {
//print("null");
mapGrab[sportEvent] = [eventInfo[i]]; mapGrab[sportEvent] = [eventInfo[i]];
} else { } else {
//print(eventInfo[i].date);
mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]); mapGrab[sportEvent] = List.from(original)..addAll([eventInfo[i]]);
} }
} }
@@ -61,6 +59,9 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
@override @override
void initState() { void initState() {
final _selectedDay = DateTime.now();
//_selectedEvents = _events[_selectedDay] ?? [];
_selectedEvents = []; _selectedEvents = [];
_calController = CalendarController(); _calController = CalendarController();
@@ -87,7 +88,8 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
super.dispose(); super.dispose();
} }
void _DaySelected(DateTime day, List events) { //void _DaySelected(DateTime day, List<sport_schedule> events) { //original that makes events work
void _DaySelected(DateTime day, List events) { //Removing the <sport_schedule> allows it to still work. Proceed with caution
setState(() { setState(() {
_selectedEvents = events; _selectedEvents = events;
selectedDay = DateTime(day.year, day.month, day.day); selectedDay = DateTime(day.year, day.month, day.day);
@@ -122,6 +124,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
calendarController: _calController, calendarController: _calController,
initialCalendarFormat: CalendarFormat.month, initialCalendarFormat: CalendarFormat.month,
startingDayOfWeek: StartingDayOfWeek.sunday, startingDayOfWeek: StartingDayOfWeek.sunday,
//availableGestures: AvailableGestures.all,
events: _events, events: _events,
availableCalendarFormats: const { availableCalendarFormats: const {
@@ -198,20 +201,15 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
markersBuilder: (context, date, events, holidays) { markersBuilder: (context, date, events, holidays) {
final miniBox = <Widget>[]; final miniBox = <Widget>[];
if (events.isNotEmpty) { if (events.isNotEmpty) {
miniBox.add( miniBox.add(
Positioned( Positioned(
right: 0,top: 0, left: 0, bottom: 0, right: 1,
child: _buildEventsMarker(date, events[0].location_indicator, true, events), bottom: 1,
child: _buildEventsMarker(date, events),
), ),
); );
if (events.length > 1)
miniBox.add(
Positioned(
right: 1, bottom: 1,
child: _buildEventsMarker(date, events[0].location_indicator, false, events),
)
);
} }
return miniBox; return miniBox;
@@ -230,20 +228,27 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
} }
//----- Creates event box display (mini box) ----- //----- Creates event box display (mini box) -----
Widget _buildEventsMarker(DateTime date, String gameType, bool main, events) { Widget _buildEventsMarker(DateTime date, List events) {
String eventNum;
if (main) {eventNum = "${date.day}";} else {eventNum = "${events.length}";}
return AnimatedContainer( return AnimatedContainer(
duration: const Duration(milliseconds: 300), duration: const Duration(milliseconds: 300),
margin: const EdgeInsets.all(4.0),
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
color: _calController.isSelected(date) shape: BoxShape.rectangle,
? Color.fromRGBO(179, 163, 105, 1) //UNCC Gold
: _gameTypeColor(gameType, main), //UNCC Green /*border: _calController.isSelected(date) //if selected date
borderRadius: BorderRadius.circular(10.0) ? Border.all(color: Colors.black, width: 1.5,)
: _calController.isToday(date) //if today's date
? Border.all(color: Colors.black, width: 1.5,)
: Border.all(color: Colors.black, width: 0,),*/
//color: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
//color: Colors.grey,
//if selected date && home game / else away game
color: _calController.isSelected(date)
? Colors.blue[400]
: Color.fromRGBO(0, 112, 60, 1), //UNCC Green
//: Colors.grey,
), ),
width: 16.0, width: 16.0,
@@ -251,7 +256,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: Center( child: Center(
child: Text( child: Text(
eventNum, '${events.length}',
style: TextStyle().copyWith( style: TextStyle().copyWith(
color: Colors.white, color: Colors.white,
fontSize: 12.0, fontSize: 12.0,
@@ -261,20 +266,6 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
); );
} }
//Logic on if Home or Away return the colors
Color _gameTypeColor(String gameType, bool main){
Color c;
if (gameType == "H"){
c = Color.fromRGBO(0, 112, 60, 1); //UNCC Green
} else {
c = Colors.grey;
}
if (!main){
c = Colors.black45;//Color.fromRGBO(179, 163, 105, 1);
}
return c;
}
//----- Creates event display ----- //----- Creates event display -----
Widget _eventLister() { Widget _eventLister() {
return ListView( return ListView(
@@ -294,7 +285,7 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
child: ListTile( child: ListTile(
leading: Image.network( leading: Image.network(
'https://charlotte49ers.com' + event.image.toString(), 'https://charlotte49ers.com' + event.image.toString(),
width: 35.0, width: 50.0,
), ),
title: Wrap( title: Wrap(
children: <Widget>[ children: <Widget>[
@@ -326,11 +317,13 @@ class _Calendar extends State<Calendar> with TickerProviderStateMixin {
subtitle: Text( subtitle: Text(
event.sportTitle.toString() + " - " + event.location.toString(), event.sportTitle.toString() + " - " + event.location.toString(),
style: TextStyle( style: TextStyle(
fontSize: 9.9, //10.3 fontSize: 10.3,
), ),
), ),
trailing: Wrap( trailing: Wrap(
//mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
//---Score--- //---Score---
//Game hasn't occured //Game hasn't occured

View File

@@ -18,7 +18,7 @@ class Feed {
class HorizontalNewsFeed extends StatelessWidget { class HorizontalNewsFeed extends StatelessWidget {
final Feed newsFeed; final Feed newsFeed;
final Text title; final Widget title;
final double numCards; final double numCards;
const HorizontalNewsFeed({ const HorizontalNewsFeed({
@@ -31,9 +31,9 @@ class HorizontalNewsFeed extends StatelessWidget {
double heightIn(BuildContext context) { double heightIn(BuildContext context) {
return MediaQuery.of(context).size.height / numCards; return MediaQuery.of(context).size.height / numCards;
} }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
//print(title.data);
return SizedBox( return SizedBox(
height: heightIn(context), height: heightIn(context),
child: Column( child: Column(
@@ -43,8 +43,8 @@ class HorizontalNewsFeed extends StatelessWidget {
title: title, title: title,
trailing: IconButton( trailing: IconButton(
icon: Icon(Icons.navigate_next), icon: Icon(Icons.navigate_next),
onPressed: () => Navigator.of(context).pushNamed('/Sport', arguments: title.data),
onPressed: () => Navigator.of(context).pushNamed('/Sport'),
/*onPressed: () { //changed /*onPressed: () { //changed
Navigator.of(context).pushNamed('/Sport'); Navigator.of(context).pushNamed('/Sport');

View File

@@ -12,15 +12,15 @@ class RouteGenerator {
static Route<dynamic> generateRoute(RouteSettings settings) { static Route<dynamic> generateRoute(RouteSettings settings) {
final args = settings final args = settings
.arguments; //This is how we pass arguments and can be used in case .arguments; //This is how we pass arguments and can be used in case
print("args $args");
switch (settings.name) { switch (settings.name) {
case '/': case '/':
return MaterialPageRoute(builder: (_) => Home()); return MaterialPageRoute(builder: (_) => Home());
case '/Sport': case '/Sport':
//We can put logic and stuff here for checking if logged in //We can put logic and stuff here for checking if logged in
return MaterialPageRoute(builder: (_) => Sport(args)); return MaterialPageRoute(builder: (_) => Sport());
case '/Schedule': case '/Schedule':
return MaterialPageRoute(builder: (_) => Schedule(args)); return MaterialPageRoute(builder: (_) => Schedule());
case '/Standing': case '/Standing':
return MaterialPageRoute(builder: (_) => Standing()); return MaterialPageRoute(builder: (_) => Standing());
case '/Chat': case '/Chat':

View File

@@ -3,17 +3,15 @@ import '../monthly_calendar.dart';
class Schedule extends StatelessWidget{ class Schedule extends StatelessWidget{
final List sport; final calendar = Calendar();
Schedule(this.sport);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
var calendar = Calendar(sport[0]);
return StatefulBuilder( return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold( builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar( appBar: AppBar(
centerTitle: false, centerTitle: false,
title: Text("${sport[1]}"), title: Text("49ers"),
backgroundColor: Colors.green, backgroundColor: Colors.green,
), ),
body: Container ( body: Container (

View File

@@ -4,43 +4,27 @@ import '../news/feed.dart';
class Sport extends StatelessWidget { class Sport extends StatelessWidget {
static final List<Item> colorList = <Item>[ static final List<Item> colorList = <Item>[
const Item('Football', Colors.green,[3]), const Item('FootBall', Colors.green),
const Item("Basketball", Colors.red,[5,13]), const Item("BasketBall", Colors.red),
const Item("Soccer", Colors.pinkAccent,[9,17]), const Item("Soccer", Colors.pinkAccent),
const Item('Baseball', Colors.orange,[1]), const Item('Baseball', Colors.orange),
const Item('Softball', Colors.yellow,[12]),
const Item('Volleyball', Colors.blue,[20]),
const Item('Tennis', Colors.yellowAccent,[10,18]),
]; ];
Item _curSport = colorList[0];
final feed = Feed(); // was var not final final feed = Feed(); // was var not final
bool genderSportSwitch = false; //determines if sport needs the gender switch bool genderSportSwitch = false; //determines if sport needs the gender switch
final String imageMale = 'images/male.png'; final String imageMale = 'images/male.png';
final String imageFemale = 'images/female.png'; final String imageFemale = 'images/female.png';
static bool genderSport = false; //determines which gender switch is set M - false / F - True static bool genderSport = false; //determines which gender switch is set M - false / F - True
static int sport_ID;
final String sport;
Sport(this.sport);
Item _curSport = colorList[0]; static int sport_ID;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Item _setDefault(){
Item _curSport;
for (Item i in colorList){
if (i.name == sport){
_curSport = i;
break;
}
}
return _curSport;
}
_curSport = _setDefault();
sport_ID = _curSport.sportID[0];
Item selectedSport; Item selectedSport;
_genderSwitcherCheck();
return StatefulBuilder( return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold( builder: (context, StateSetter setState) => Scaffold(
appBar: AppBar( appBar: AppBar(
@@ -48,15 +32,22 @@ class Sport extends StatelessWidget {
title: buildDropdownButton(selectedSport, setState), title: buildDropdownButton(selectedSport, setState),
backgroundColor: _curSport.color, backgroundColor: _curSport.color,
//--Gender Switch-- //--Gender Switch-- Need to make condition to determine gender
actions: <Widget>[ actions: <Widget>[
if (genderSportSwitch) if (genderSportSwitch == true)
Switch( Switch(
value: genderSport, value: genderSport,
onChanged: (value) { onChanged: (value) {
setState(() { setState(() {
genderSport = value; if (value == false) {
_genderSwitcherCheck(); genderSport = false;
}
else {
genderSport = true;
}
print("value: " + value.toString());
print("gender: " + genderSport.toString());
}); });
}, },
inactiveThumbColor: Colors.lightBlue, inactiveThumbColor: Colors.lightBlue,
@@ -99,13 +90,13 @@ class Sport extends StatelessWidget {
ListTile( ListTile(
title: IconButton( title: IconButton(
icon: Icon(Icons.table_chart), icon: Icon(Icons.table_chart),
onPressed: () => Navigator.pushNamed(context, '/Standing', arguments: sport_ID), onPressed: () => Navigator.pushNamed(context, '/Standing'),
), ),
), ),
ListTile( ListTile(
title: IconButton( title: IconButton(
icon: Icon(Icons.calendar_today), icon: Icon(Icons.calendar_today),
onPressed: () => Navigator.pushNamed(context, '/Schedule',arguments: [sport_ID, _curSport.name],), onPressed: () => Navigator.pushNamed(context, '/Schedule'),
), ),
), ),
], ],
@@ -115,7 +106,8 @@ class Sport extends StatelessWidget {
); );
} }
DropdownButtonHideUnderline buildDropdownButton(Item selectedSport, StateSetter setState) { DropdownButtonHideUnderline buildDropdownButton(
Item selectedSport, StateSetter setState) {
return DropdownButtonHideUnderline( return DropdownButtonHideUnderline(
child: DropdownButton<Item>( child: DropdownButton<Item>(
value: selectedSport, value: selectedSport,
@@ -131,7 +123,44 @@ class Sport extends StatelessWidget {
onChanged: (Item value) { onChanged: (Item value) {
setState(() { setState(() {
_curSport = value; _curSport = value;
_genderSwitcherCheck();
print("genderSport: " + genderSport.toString());
//Will set the sport id / Display gender switch
switch (_curSport.name) { //prints are temp
case 'FootBall':
genderSportSwitch = false;
sport_ID = 3;
break;
case 'BasketBall':
genderSportSwitch = true;
if (genderSport == false) {
sport_ID = 5; //Male
}
else {
sport_ID = 13; //Female
}
break;
case 'Soccer':
genderSportSwitch = true;
if (genderSport == false) {
sport_ID = 9; //Male
}
else {
sport_ID = 17; //Female
}
break;
case 'Baseball':
genderSportSwitch = false;
sport_ID = 1;
break;
}
print(sport_ID); print(sport_ID);
}); });
}, },
@@ -147,25 +176,11 @@ class Sport extends StatelessWidget {
), ),
); );
} }
void _genderSwitcherCheck() {
if (_curSport.name == "Soccer" || _curSport.name == "Basketball" || _curSport.name == "Tennis" ){
genderSportSwitch = true;
sport_ID = genderSport ? _curSport.sportID[1] : _curSport.sportID[0];
} else {
genderSportSwitch = false;
sport_ID = _curSport.sportID[0];
}
print(sport_ID);
}
} }
class Item { class Item {
const Item(this.name, this.color, this.sportID); const Item(this.name, this.color);
final String name; final String name;
final Color color; final Color color;
final List<int> sportID; }
}

View File

@@ -3,25 +3,10 @@ import 'package:flutter/material.dart';
import '../twitter_assets/tweet.dart'; import '../twitter_assets/tweet.dart';
class TwitterFeed extends StatelessWidget{ class TwitterFeed extends StatelessWidget{
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 lets celebrate together virtually \n Were 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 @override
Widget build(BuildContext context) { 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( return StatefulBuilder(
builder: (context, StateSetter setState) => Scaffold( builder: (context, StateSetter setState) => Scaffold(
@@ -33,7 +18,16 @@ class TwitterFeed extends StatelessWidget{
body: Container( body: Container(
color: Colors.black12, color: Colors.black12,
child: child:
VerticalTwitterFeed(twitterFeed: fuck), FutureBuilder(
future: _buildTwitter(),
builder: (ctx, snapshot){
if(!snapshot.hasData){
return Center(child: CircularProgressIndicator());
}else{
return snapshot.data;
}
},
),
), ),
drawer: Drawer( drawer: Drawer(
child: ListView( child: ListView(
@@ -63,3 +57,7 @@ class TwitterFeed extends StatelessWidget{
} }
} }
Future<VerticalTwitterFeed> _buildTwitter() async {
final feed = TwitterFeedCreation();
return VerticalTwitterFeed(twitterFeed: feed);
}

View File

@@ -3,29 +3,29 @@ import 'package:flutter/material.dart';
class Tweet { class Tweet {
final int id; final int id;
final String text; final String text;
final String userName; //final String userName;
final String userImgUrl; //final String userImgUrl;
final String url; //final String url;
Tweet( Tweet(
this.id, this.id, {
this.text, this.text,
this.userName, // this.userName,
this.userImgUrl, // this.userImgUrl,
this.url, // this.url,
}
); );
/*factory Tweet.fromJson(Map<String, dynamic> json) { factory Tweet.fromJson(Map<String, dynamic> json) {
return Tweet( return Tweet(
json['id_str'], json['id_str'],
text: json['text'], text: json['full_text'],
userName: json['user']['name'], //userName: json['user']['name'],
userImgUrl: json['user']['profile_image_url_https'], //userImgUrl: json['user']['profile_image_url_https'],
url: json['urls']['expanded_url'], //url: json['urls']['expanded_url'],
); );
} }
Commenting out till we figure out the API
*/
@@ -46,7 +46,7 @@ class TwitterCard extends StatelessWidget{
child: Padding( child: Padding(
padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0), padding: EdgeInsets.symmetric(vertical: 10, horizontal: 0),
child: ListTile( child: ListTile(
leading: SizedBox( /* leading: SizedBox(
height: 150, height: 150,
width: 75, width: 75,
child: Container( child: Container(
@@ -58,9 +58,9 @@ class TwitterCard extends StatelessWidget{
), ),
), ),
), ),
), ), */
title: Text('${tweet.userName}'), // title: Text('${tweet.userName}'),
subtitle: Text('${tweet.text}'), title: Text('${tweet.text}'),
), ),
), ),
); );

View File

@@ -3,44 +3,85 @@ import 'dart:io';
import 'package:capstone_hungry_hippos/screens/twitter_widget.dart'; import 'package:capstone_hungry_hippos/screens/twitter_widget.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:http/http.dart' as http; import 'package:http/http.dart' as http;
import 'package:twitter_api/twitter_api.dart';
import'package:crypto/crypto.dart';
import 'dart:convert'; import 'dart:convert';
import 'tweet.dart'; import 'tweet.dart';
final twitterBase = 'https://api.twitter.com/1.1/search';
final _twitterOauth = new twitterApi(
consumerKey: "gsa3eHPVGK90dt6fgUC2ZSbTE",
consumerSecret: "rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5V",
token: "910563313108574211-WynoAeUKJrnE6uXPv8vJGx4ITGS1ggG",
tokenSecret: "dWFYYbn6J1QTyV86femOdriX7MfMSANSjH3m48ZtEZUNW",
);
class TwitterFeedCreation { class TwitterFeedCreation {
static final twitterBase = 'https://api.twitter.com/1.1/search';
static final apiKey = 'AFBfOqx8uXIUBZMxAFoQyO3zA';
static final apiSecret = '48Gp7nczz9SqExorwYuWpA6Nmviuox6Beq83kjH1XtYtunorym';
getToken() async { Future<List<Tweet>> getPage() async {
http.Response response = await http.get('https://api.twitter.com/oauth2/token',);
}
/*Future<List<Tweet>> getPage({int size = 10}) async {
var url = '$twitterBase/tweets.json?q=from%3ACharlotteFTBL&result_type=mixed&count=$size'; var response = await _twitterOauth.getTwitterRequest(
http.Response response = await http.get(url, "GET",
headers: <String, String> {'authorization': apiKey,} "/statuses/user_timeline.json",
options: {
"user_id": "19025957",
"screen_name": "TTCnotices",
"count": "20",
"trim_user": "true",
"tweet_mode": "extended",
}
); );
Iterable tweets = json.decode(response.body); Iterable tweets = json.decode(response.body);
print(tweets);
return tweets.map((e) => Tweet.fromJson(e)).toList(); return tweets.map((e) => Tweet.fromJson(e)).toList();
} */
}
} }
String _getSig(String method, String base, List<String> sortedItems){
String param = '';
for (int i = 0; i < sortedItems.length; i++) {
if (i == 0) {
param = sortedItems[i];
} else {
param += '%${sortedItems[i]}';
}
}
String sig = '$method&${Uri.encodeComponent(base)}&${Uri.encodeComponent(param)}';
String key = '${Uri.encodeComponent("gsa3eHPVGK90dt6fgUC2ZSbTE")}&${Uri.encodeComponent("rwEjykGOfapPLTVkWgedSCU8Eld130EEHFyu3W0Ye3fDcKj5V")}';
var digest = Hmac(sha1, utf8.encode(key)).convert(utf8.encode(sig));
return base64.encode(digest.bytes);
}
class VerticalTwitterFeed extends StatelessWidget{ class VerticalTwitterFeed extends StatelessWidget{
final List<Tweet> twitterFeed; final TwitterFeedCreation twitterFeed;
const VerticalTwitterFeed({ const VerticalTwitterFeed({
Key key, Key key,
@required this.twitterFeed, @required this.twitterFeed,
}) : super(key: key); }) : super(key: key);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
/*
return Container( return Container(
child: ListView.builder( child: ListView.builder(
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
@@ -51,9 +92,9 @@ class VerticalTwitterFeed extends StatelessWidget{
); );
}, },
), ),
); ); */
/* return Container( return Container(
child: FutureBuilder( child: FutureBuilder(
future: twitterFeed.getPage(), future: twitterFeed.getPage(),
builder: (ctx, snapshot){ builder: (ctx, snapshot){
@@ -73,6 +114,8 @@ class VerticalTwitterFeed extends StatelessWidget{
} }
}, },
), ),
); */ );
} }
} }

View File

@@ -58,7 +58,7 @@ packages:
source: hosted source: hosted
version: "2.1.1" version: "2.1.1"
crypto: crypto:
dependency: transitive dependency: "direct main"
description: description:
name: crypto name: crypto
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
@@ -273,6 +273,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.2.11" version: "0.2.11"
twitter_api:
dependency: "direct main"
description:
name: twitter_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

View File

@@ -24,6 +24,8 @@ dependencies:
http: ^0.12.0+4 http: ^0.12.0+4
shared_preferences: ^0.5.6+3 shared_preferences: ^0.5.6+3
twitter_api: ^0.1.2
crypto:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.