Commit a49ba1f0 authored by Brian Runck's avatar Brian Runck
Browse files

renew api key for the 1000th time cuz call limit

parent 54a8e8b6
......@@ -113,19 +113,22 @@ class _HomePageState extends State<HomePage> {
Future<List<dynamic>> getMonkeyOpinion(String text) async {
var lol = json.encode({"data": [text]});
var soos;
Response response;
//print(lol);
Response response = await http.post( Uri.encodeFull(URLS.Monkey_URL),
headers: {
"Authorization" : "Token 81dd05f9b6adcd8d8c6a59afe4d94d0dcebdeb1c",
"Content-Type" : "application/json"
},
body:
do {
response = await http.post(Uri.encodeFull(URLS.Monkey_URL),
headers: {
"Authorization": "Token 7c38e7d156c2df08ad924f18ca62a6357361a17f",
"Content-Type": "application/json"
},
body:
lol
);
var soos = jsonDecode(response.body);
);
//print(soos);
soos = jsonDecode(response.body);
} while (soos[0]["classifications"][0]["tag_name"]==null);
return json.decode(response.body);
......@@ -141,7 +144,7 @@ class _HomePageState extends State<HomePage> {
final _biggerFont = TextStyle(fontSize: 18.0);
return ListView.builder(
padding: EdgeInsets.symmetric(vertical: 0,horizontal: 10),
padding: EdgeInsets.symmetric(vertical: 20,horizontal: 20),
itemCount: 88,
itemBuilder: (BuildContext context, int index) {
......@@ -159,7 +162,7 @@ class _HomePageState extends State<HomePage> {
direction: MediaQuery.of(context).size.width>670 ? Axis.horizontal : Axis.vertical,
children: [Image.network(
Uri.encodeFull(_suggestions["results"][index~/2]["multimedia"][0]["url"]),
height: 180),
height: 220),
SizedBox(width: 50),
Expanded(
flex: MediaQuery.of(context).size.width>670 ? 3 : 0,
......@@ -185,31 +188,104 @@ class _HomePageState extends State<HomePage> {
);
default:
if (snapshot.hasError)
return new Text('Error: ${snapshot.error}');
else
return Column( children: [
Flex( direction: MediaQuery.of(context).size.width>828 || MediaQuery.of(context).size.width>598 && MediaQuery.of(context).size.width<670 ? Axis.horizontal : Axis.vertical,
children: [Row(children: [
Container( width : 40, height : 40,
child :
FlutterGauge(backgroundColor : getSentimColor((snapshot.data[0]["result"]["polarity"]*50+50).toInt()), circleColor : getSentimColor((snapshot.data[0]["result"]["polarity"]*50+50).toInt()), secondsMarker: SecondsMarker.none, widthCircle: 4, hand: Hand.short,number: Number.none,width: 5,index: snapshot.data[0]["result"]["polarity"]*50+50,fontFamily: "Iran",counterStyle: TextStyle(color: Colors.black,fontSize: 14),counterAlign: CounterAlign.center,isDecimal: false),
),
Text(" 1. Sentim-API : ${snapshot.data[0]["result"]["type"]} " , style: anal)],),
Text("Polarity : ${snapshot.data[0]["result"]["polarity"]}" , style: anal)],
),
Flex( direction: MediaQuery.of(context).size.width>828 || MediaQuery.of(context).size.width>598 && MediaQuery.of(context).size.width<670 ? Axis.horizontal : Axis.vertical,
children: [Row(children: [
Container( width : 40, height : 40,
child :
FlutterGauge(backgroundColor : getMonkeyColor(snapshot.data[1][0]["classifications"][0]["tag_name"]=="Neutral",(snapshot.data[1][0]["classifications"][0]["confidence"]*100).toInt()), circleColor : getMonkeyColor(snapshot.data[1][0]["classifications"][0]["tag_name"]=="Neutral",(snapshot.data[1][0]["classifications"][0]["confidence"]*100).toInt()), secondsMarker: SecondsMarker.none, widthCircle: 4, hand: Hand.short,number: Number.none,width: 5,index: snapshot.data[1][0]["classifications"][0]["confidence"]*100,fontFamily: "Iran",counterStyle: TextStyle(color: Colors.black,fontSize: 14),counterAlign: CounterAlign.center,isDecimal: false),
),
Text(" 2. Monkeylearn-API : ${snapshot.data[1][0]["classifications"][0]["tag_name"]} " , style: anal)],),Text("Confidence : ${snapshot.data[1][0]["classifications"][0]["confidence"]}" , style: anal)],
),
if (snapshot.hasError) {
return Center(
heightFactor: 2,
child: CircularProgressIndicator(),
);
}
else {
return Column(children: [
Flex(direction: MediaQuery
.of(context)
.size
.width > 828 || MediaQuery
.of(context)
.size
.width > 598 && MediaQuery
.of(context)
.size
.width < 670 ? Axis.horizontal : Axis.vertical,
children: [Row(children: [
Container(width: 40, height: 40,
child:
FlutterGauge(backgroundColor: getSentimColor(
(snapshot.data[0]["result"]["polarity"] * 50 + 50)
.toInt()),
circleColor: getSentimColor(
(snapshot.data[0]["result"]["polarity"] * 50 +
50).toInt()),
secondsMarker: SecondsMarker.none,
widthCircle: 4,
hand: Hand.short,
number: Number.none,
width: 5,
index: snapshot.data[0]["result"]["polarity"] * 50 +
50,
fontFamily: "Iran",
counterStyle: TextStyle(
color: Colors.black, fontSize: 14),
counterAlign: CounterAlign.center,
isDecimal: false),
),
Text(" 1. Sentim-API : ${snapshot
.data[0]["result"]["type"]} ",
style: anal)
],),
Text("Polarity : ${snapshot
.data[0]["result"]["polarity"]}", style: anal)
],
),
Flex(direction: MediaQuery
.of(context)
.size
.width > 828 || MediaQuery
.of(context)
.size
.width > 598 && MediaQuery
.of(context)
.size
.width < 670 ? Axis.horizontal : Axis.vertical,
children: [
Row(children: [
Container(width: 40, height: 40,
child:
FlutterGauge(backgroundColor: getMonkeyColor(snapshot
.data[1][0]["classifications"][0]["tag_name"] ==
"Neutral", (snapshot
.data[1][0]["classifications"][0]["confidence"] *
100).toInt()),
circleColor: getMonkeyColor(snapshot
.data[1][0]["classifications"][0]["tag_name"] ==
"Neutral", (snapshot
.data[1][0]["classifications"][0]["confidence"] *
100).toInt()),
secondsMarker: SecondsMarker.none,
widthCircle: 4,
hand: Hand.short,
number: Number.none,
width: 5,
index: snapshot
.data[1][0]["classifications"][0]["confidence"] *
100,
fontFamily: "Iran",
counterStyle: TextStyle(
color: Colors.black, fontSize: 14),
counterAlign: CounterAlign.center,
isDecimal: false),
),
Text(" 2. Monkeylearn-API : ${snapshot
.data[1][0]["classifications"][0]["tag_name"]} ",
style: anal)
],),
Text("Confidence : ${snapshot
.data[1][0]["classifications"][0]["confidence"]}",
style: anal)
],
),
]
);
}
}
})
]
......@@ -329,10 +405,14 @@ class _HomePageState extends State<HomePage> {
child : CircularProgressIndicator(),
);
default:
if (snapshot.hasError)
return new Container( height: 100, child: Text('Error: ${snapshot.error}'));
else
return snapshot.data;
if (snapshot.hasError) {
return Center (
child : CircularProgressIndicator(),
);
}
else {
return snapshot.data;
}
}
}
)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment