Skip to content

Commit d2cb470

Browse files
authored
Merge pull request #4 from AndersonOli/settings
Settings
2 parents 3d80527 + 5e8f757 commit d2cb470

File tree

9 files changed

+383
-353
lines changed

9 files changed

+383
-353
lines changed
Lines changed: 100 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,111 @@
11
import 'package:flutter/material.dart';
22
import 'package:helppyapp/app/components/news/card_counter_disease_component.dart';
33
import 'package:url_launcher/url_launcher.dart';
4+
import 'package:http/http.dart' as http;
45

56
class BuildNews extends StatelessWidget {
6-
final AsyncSnapshot snapshot;
7-
BuildNews(this.snapshot);
7+
final AsyncSnapshot snapshot;
8+
BuildNews(this.snapshot);
89

9-
@override
10-
Widget build(BuildContext context) {
11-
return ListView.builder(
12-
itemCount: snapshot.data[0]["articles"].length,
13-
itemBuilder: (context, index) {
14-
var descricao = snapshot.data[0]["articles"][index]["description"];
10+
@override
11+
Widget build(BuildContext context) {
12+
return ListView.builder(
13+
itemCount: snapshot.data[0]["articles"].length,
14+
itemBuilder: (context, index) {
15+
var descricao = snapshot.data[0]["articles"][index]["description"];
1516

16-
if (descricao.length > 110) {
17-
descricao = descricao.substring(0, 110) + "...";
18-
} else if(descricao == "" || descricao == null) {
19-
descricao = snapshot.data[0]["articles"][index]["title"];
20-
}
17+
if (descricao.length > 110) {
18+
descricao = descricao.substring(0, 110) + "...";
19+
} else if (descricao == "" || descricao == null) {
20+
descricao = snapshot.data[0]["articles"][index]["title"];
21+
}
2122

22-
if (index == 0) {
23-
return CardCases();
24-
} else {
25-
return _cardNews(snapshot, index, descricao);
26-
}
27-
},
28-
);
23+
if (index == 0) {
24+
return CardCases();
25+
} else {
26+
return _cardNews(snapshot, index, descricao);
27+
}
28+
},
29+
);
30+
}
31+
32+
Future<bool> checkUrl(String url) async {
33+
try {
34+
var statusCode = await http.get(url);
35+
36+
if (statusCode.statusCode == 200 || statusCode.statusCode == 204) {
37+
return true;
38+
}
39+
40+
return false;
41+
} catch (e) {
42+
return null;
2943
}
44+
}
3045

31-
Widget _cardNews(AsyncSnapshot snapshot, int index, String descricao) {
32-
return GestureDetector(
33-
onTap: () async {
34-
await launch(snapshot.data[0]["articles"][index]["url"], forceWebView: true, enableJavaScript: true);
35-
},
36-
child: SizedBox(
37-
height: 110,
38-
child: Card(
39-
elevation: 0.0,
40-
margin: EdgeInsets.only(top: 6.0, bottom: 6.0),
41-
child: Row(
42-
children: <Widget>[
43-
ClipRRect(
44-
borderRadius: BorderRadius.only(
45-
topLeft: Radius.circular(4),
46-
bottomLeft: Radius.circular(4),
47-
),
48-
child: Image.network(
49-
snapshot.data[0]["articles"][index]["urlToImage"] ??
50-
"https://www.coronavirus.ms.gov.br/wp-content/uploads/2020/04/coronavirus-1.jpg",
51-
width: 150.0,
52-
height: 100.0,
53-
fit: BoxFit.fill,
54-
),
55-
),
56-
Expanded(
57-
child: Container(
58-
padding: EdgeInsets.only(left: 10.0, right: 10.0),
59-
child: Text(
60-
descricao,
61-
textAlign: TextAlign.justify,
62-
),
63-
),
64-
)
65-
],
66-
),
46+
Widget _cardNews(AsyncSnapshot snapshot, int index, String descricao) {
47+
var image = snapshot.data[0]["articles"][index]["urlToImage"];
48+
return GestureDetector(
49+
onTap: () async {
50+
await launch(snapshot.data[0]["articles"][index]["url"],
51+
forceWebView: true, enableJavaScript: true);
52+
},
53+
child: SizedBox(
54+
height: 110,
55+
child: Card(
56+
elevation: 0.0,
57+
margin: EdgeInsets.only(top: 6.0, bottom: 6.0),
58+
child: Row(
59+
children: <Widget>[
60+
FutureBuilder(
61+
future:
62+
checkUrl(snapshot.data[0]["articles"][index]["urlToImage"]),
63+
builder: (context, snapshot) {
64+
if (snapshot.connectionState == ConnectionState.waiting ||
65+
snapshot.connectionState == ConnectionState.none) {
66+
return Container(
67+
width: 150.0,
68+
height: 100.0,
69+
color: Colors.grey,
70+
child: Icon(Icons.image),
71+
);
72+
} else {
73+
if (snapshot.data) {
74+
return ClipRRect(
75+
borderRadius: BorderRadius.only(
76+
topLeft: Radius.circular(4),
77+
bottomLeft: Radius.circular(4),
78+
),
79+
child: Image.network(
80+
image,
81+
width: 150.0,
82+
height: 100.0,
83+
fit: BoxFit.fill,
84+
));
85+
} else {
86+
return Container(
87+
width: 150.0,
88+
height: 100.0,
89+
color: Colors.grey,
90+
child: Icon(Icons.image),
91+
);
92+
}
93+
}
94+
},
95+
),
96+
Expanded(
97+
child: Container(
98+
padding: EdgeInsets.only(left: 10.0, right: 10.0),
99+
child: Text(
100+
descricao,
101+
textAlign: TextAlign.justify,
102+
),
67103
),
68-
),
69-
);
70-
}
71-
}
104+
)
105+
],
106+
),
107+
),
108+
),
109+
);
110+
}
111+
}

lib/app/controllers/register_controller.dart

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ abstract class _RegisterController with Store {
3737
}
3838

3939
Future<void> uploadImage() async {
40-
print('hi');
4140
if (fileProfileImage != null) {
4241
final FirebaseStorage _storage =
4342
FirebaseStorage(storageBucket: 'gs://helppy-19-893b1.appspot.com');
@@ -251,7 +250,6 @@ abstract class _RegisterController with Store {
251250
statusRegister = 2;
252251
} else if (data.body
253252
.contains(emailCadController.text.toLowerCase().trim())) {
254-
print('hi');
255253
http.Response data = await http.post(
256254
API_URL + '/authenticate',
257255
headers: <String, String>{

lib/app/controllers/settings_controller.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ abstract class _SettingsController with Store {
2929
}
3030

3131
Future<void> uploadImage() async {
32-
print('hi');
3332
if (fileProfileImage != null) {
3433
final FirebaseStorage _storage =
3534
FirebaseStorage(storageBucket: 'gs://helppy-19-893b1.appspot.com');

lib/app/pages/forgot_password/change_password_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class _ChangePasswordState extends State<ChangePassword> {
5757
Container(
5858
margin: EdgeInsets.only(top: 20.0),
5959
child: Text(
60-
"\t\t\t\tstandard dummy text ever since the of type and scrambled it to make a type specimen book.",
60+
"\t\t\t\tInsira o código que foi enviado para seu email e caso não encontre, verifique sua caixa de spam.",
6161
style: TextStyle(
6262
color: COR_AZUL,
6363
fontSize: 16.0

lib/app/pages/forgot_password/forgot_password_page.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ class _ForgotPasswordState extends State<ForgotPassword> {
9696
Container(
9797
margin: EdgeInsets.only(top: 20.0),
9898
child: Text(
99-
"\t\t\t\tLorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.",
99+
"\t\t\t\tEsta é uma área que caso você tenha esquecido a sua senha, irá ajudar a obter uma nova. Em caso de dúvidas, entre em contato com a nossa equipe pelo email: helppy19@hotmail.com",
100100
style: TextStyle(
101101
color: COR_AZUL,
102102
fontSize: 16.0

lib/app/pages/news/news_page.dart

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,59 +6,60 @@ import 'dart:convert' as convert;
66
import 'package:http/http.dart' as http;
77

88
class NewsTab extends StatefulWidget {
9-
@override
10-
_NewsTabState createState() => _NewsTabState();
9+
@override
10+
_NewsTabState createState() => _NewsTabState();
1111
}
1212

13-
class _NewsTabState extends State<NewsTab> with AutomaticKeepAliveClientMixin<NewsTab> {
14-
Future _futureData;
13+
class _NewsTabState extends State<NewsTab>
14+
with AutomaticKeepAliveClientMixin<NewsTab> {
15+
Future _futureData;
1516

16-
@override
17-
void initState() {
18-
super.initState();
19-
_futureData = newsData();
20-
}
17+
@override
18+
void initState() {
19+
super.initState();
20+
_futureData = newsData();
21+
}
2122

22-
Future<List> newsData() async {
23-
var response = await http.get('http://newsapi.org/v2/everything?language=pt&q=coronavirus brazil&?country=br&apiKey=3aaaaf0e6ab44bdea5e9806c43ee6447');
24-
return [convert.jsonDecode(response.body)];
25-
}
23+
Future<List> newsData() async {
24+
//http://newsapi.org/v2/everything?language=pt&q=coronavirus brazil&?country=br&apiKey=3aaaaf0e6ab44bdea5e9806c43ee6447
25+
//
26+
var response = await http.get(
27+
'http://newsapi.org/v2/everything?language=pt&q=covid%20brasil&?country=br&apiKey=3aaaaf0e6ab44bdea5e9806c43ee6447');
28+
return [convert.jsonDecode(response.body)];
29+
}
2630

27-
@override
28-
Widget build(BuildContext context) {
29-
super.build(context);
30-
return Padding(
31-
padding: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
32-
child: Column(
33-
children: <Widget>[
34-
Expanded(
35-
child: FutureBuilder(
36-
future: _futureData,
37-
builder: (context, snapshot) {
38-
if(snapshot.connectionState == ConnectionState.waiting){
39-
return loadingCenter();
40-
} else {
41-
if(snapshot.hasData){
42-
return BuildNews(snapshot);
43-
} else {
44-
return Center(
45-
child: Text(
46-
"Verifique sua conexão com a internet.",
47-
style: TextStyle(
48-
color: COR_AZUL,
49-
fontSize: 14.0
50-
),
51-
),
52-
);
53-
}
54-
}
55-
}),
56-
),
57-
],
58-
),
59-
);
60-
}
31+
@override
32+
Widget build(BuildContext context) {
33+
super.build(context);
34+
return Padding(
35+
padding: EdgeInsets.only(top: 10.0, left: 10.0, right: 10.0),
36+
child: Column(
37+
children: <Widget>[
38+
Expanded(
39+
child: FutureBuilder(
40+
future: _futureData,
41+
builder: (context, snapshot) {
42+
if (snapshot.connectionState == ConnectionState.waiting) {
43+
return loadingCenter();
44+
} else {
45+
if (snapshot.hasData) {
46+
return BuildNews(snapshot);
47+
} else {
48+
return Center(
49+
child: Text(
50+
"Verifique sua conexão com a internet.",
51+
style: TextStyle(color: COR_AZUL, fontSize: 14.0),
52+
),
53+
);
54+
}
55+
}
56+
}),
57+
),
58+
],
59+
),
60+
);
61+
}
6162

62-
@override
63-
bool get wantKeepAlive => true;
64-
}
63+
@override
64+
bool get wantKeepAlive => true;
65+
}

lib/app/pages/requests/accept_request_page.dart

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,8 @@ class _AcceptRequestState extends State<AcceptRequest> {
219219
return FlatButton(
220220
padding: EdgeInsets.symmetric(vertical: 10.0, horizontal: 50.0),
221221
onPressed: () async {
222-
isLoading(context, true);
223222
var response;
223+
isLoading(context, true);
224224
var url = API_URL + '/update/' + info["user_id"].toString() + "/" + info["id"].toString();
225225
if(prefs['onRequest'] != 1){
226226
response = await http.post(
@@ -233,8 +233,6 @@ class _AcceptRequestState extends State<AcceptRequest> {
233233
})
234234
);
235235

236-
//TODO: analisar responde e fazer algo com ele
237-
238236
isLoading(context, false);
239237

240238
controller.setPreferences('onRequest', 1);

lib/app/pages/settings/settings_update_user.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'dart:io';
21
import 'package:flutter/material.dart';
32
import 'package:flutter_mobx/flutter_mobx.dart';
43
import 'package:helppyapp/app/components/general/globals_component.dart';

0 commit comments

Comments
 (0)