Skip to content

Commit

Permalink
Merge pull request #36 from fga-eps-mds/feature/98-Productor-details
Browse files Browse the repository at this point in the history
#98 [US12] - Visualizar Anúncios de um Produtor
  • Loading branch information
VitorLamego authored Apr 22, 2021
2 parents 13c7c49 + 7ca27b3 commit db24bf0
Show file tree
Hide file tree
Showing 21 changed files with 429 additions and 43 deletions.
2 changes: 2 additions & 0 deletions hortum_mobile/lib/components/announcement_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class AnnouncementBox extends StatefulWidget {
final String localization;
final String price;
final String productPic;
final String email;

const AnnouncementBox(
{@required this.profilePic,
Expand All @@ -15,6 +16,7 @@ class AnnouncementBox extends StatefulWidget {
@required this.localization,
@required this.price,
@required this.productPic,
@required this.email,
Key key})
: super(key: key);
@override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import 'package:flutter/material.dart';

class CircleStyle extends StatelessWidget {
class CircleStyle extends StatefulWidget {
final Color color;
final double opacity;

const CircleStyle({@required this.color, @required this.opacity, Key key})
: super(key: key);
@override
_CircleStyleState createState() => _CircleStyleState();
}

class _CircleStyleState extends State<CircleStyle> {
@override
Widget build(BuildContext context) {
return Align(
Expand All @@ -10,7 +20,7 @@ class CircleStyle extends StatelessWidget {
width: 100,
decoration: BoxDecoration(
shape: BoxShape.rectangle,
color: Color(0xff478C5C).withOpacity(0.2),
color: widget.color.withOpacity(widget.opacity),
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(250))),
),
);
Expand Down
12 changes: 10 additions & 2 deletions hortum_mobile/lib/components/productors_box.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import 'package:flutter/material.dart';
import 'package:hortum_mobile/services/codec_string.dart';
import 'package:hortum_mobile/views/productor_details/productor_details.dart';

class ProductorsBox extends StatefulWidget {
final String name;
final String imageAsset;
final String email;

const ProductorsBox({@required this.name, this.imageAsset, Key key})
const ProductorsBox(
{@required this.name, this.imageAsset, @required this.email, Key key})
: super(key: key);
@override
_ProductorsBoxState createState() => _ProductorsBoxState();
Expand Down Expand Up @@ -32,7 +36,11 @@ class _ProductorsBoxState extends State<ProductorsBox> {
offset: Offset(0, 4))
]),
child: MaterialButton(
onPressed: () {},
onPressed: () {
Navigator.push(context, MaterialPageRoute(builder: (context) {
return ProductorDetails(email: encodeString(widget.email));
}));
},
child: Row(
children: [
Container(
Expand Down
41 changes: 41 additions & 0 deletions hortum_mobile/lib/components/profile_picture.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import 'package:flutter/material.dart';

class ProfilePicture extends StatefulWidget {
final double width;
final double heigth;
final double radius;
final double bottomMargin;

const ProfilePicture(
{@required this.width,
@required this.heigth,
@required this.radius,
@required this.bottomMargin,
Key key})
: super(key: key);
@override
_ProfilePictureState createState() => _ProfilePictureState();
}

class _ProfilePictureState extends State<ProfilePicture> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
margin:
EdgeInsets.only(top: size.height * 0.1, bottom: widget.bottomMargin),
width: widget.width,
height: widget.heigth,
child: ClipRRect(
borderRadius: BorderRadius.all(Radius.circular(widget.radius)),
child: Material(
child: InkWell(
child: Image.asset(
'assets/images/perfil.jpg',
fit: BoxFit.fill,
)),
),
),
);
}
}
21 changes: 21 additions & 0 deletions hortum_mobile/lib/components/spin.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';

class SpinWidget extends StatefulWidget {
final double margin;

const SpinWidget({@required this.margin, Key key}) : super(key: key);

@override
_SpinWidgetState createState() => _SpinWidgetState();
}

class _SpinWidgetState extends State<SpinWidget> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.only(top: widget.margin),
child: SpinKitCircle(
key: Key('spin'), color: Color(0xff47CC70).withOpacity(0.7)));
}
}
27 changes: 27 additions & 0 deletions hortum_mobile/lib/data/productor_details_backend.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:dio/dio.dart';
import 'package:hortum_mobile/globals.dart';

class ProductorsDetailsApi {
Dio dio;
List<dynamic> announcements = [];

ProductorsDetailsApi([Dio client]) {
if (client == null)
this.dio = Dio();
else
this.dio = client;
}

Future getDetails(String email) async {
//Trocar o IPLOCAL pelo ip de sua máquina
String url;
url = 'http://$ip:8000/announcement/retrieve/${email}';

var header = {
"Content-Type": "application/json",
"Authorization": "Bearer " + actualUser.tokenAccess,
};
Response response = await dio.get(url, options: Options(headers: header));
this.announcements = response.data;
}
}
3 changes: 1 addition & 2 deletions hortum_mobile/lib/services/codec_string.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:convert';


String encodeString(String str) {
var strInt = utf8.encode(str);
return base64.encode(strInt);
Expand All @@ -9,4 +8,4 @@ String encodeString(String str) {
String decodeString(String str) {
var strInt = base64.decode(str);
return utf8.decode(strInt);
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:hortum_mobile/components/circle_style.dart';
import 'package:hortum_mobile/components/footer.dart';
import 'package:hortum_mobile/views/change_password/components/password_form.dart';
import 'package:hortum_mobile/views/profile/components/circle_style.dart';

class ChangePasswordPage extends StatefulWidget {
final Dio dio;
Expand All @@ -25,7 +25,7 @@ class _ChangePasswordState extends State<ChangePasswordPage> {
height: size.height,
child: Stack(
children: [
CircleStyle(),
CircleStyle(color: Color(0xff478C5C), opacity: 0.2),
Container(
padding: EdgeInsets.only(
right: size.width * 0.1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class _AnnouncementsListState extends State<AnnouncementsList> {
itemBuilder: (context, index) {
return AnnouncementBox(
profilePic: 'assets/images/perfil.jpg',
email: announcements[index]['email'],
name: announcements[index]['username'],
title: announcements[index]['name'],
localization: 'Asa Norte, 404 Feira Da Tarde',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class _ProductorsListState extends State<ProductorsList> {
return ProductorsBox(
key: Key(productors[index]['username'] + " key"),
name: productors[index]['username'],
email: productors[index]['email'],
imageAsset: productors[index]['idPicture']);
},
)
Expand Down
8 changes: 2 additions & 6 deletions hortum_mobile/lib/views/home_customer/home_customer_page.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_spinkit/flutter_spinkit.dart';
import 'package:hortum_mobile/components/footer.dart';
import 'package:hortum_mobile/components/spin.dart';
import 'package:hortum_mobile/data/announ_data_backend.dart';
import 'package:hortum_mobile/data/productors_data_backend.dart';
import 'package:hortum_mobile/views/home_customer/components/carroussel.dart';
Expand Down Expand Up @@ -69,11 +69,7 @@ class _CustomerHomePageState extends State<CustomerHomePage> {
? this.isAnnouncements
? AnnouncementsList(announData: announData)
: ProductorsList(productorsData: productorsData)
: Container(
margin: EdgeInsets.only(top: size.height * 0.25),
child: SpinKitCircle(
key: Key('spin'),
color: Color(0xff47CC70).withOpacity(0.7))),
: SpinWidget(margin: size.height * 0.25),
],
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class _ListAnnouncementState extends State<ListAnnouncement> {
AnnouncementBox(
profilePic: 'assets/images/perfil.jpg',
name: announcements[index]['username'],
email: announcements[index]['email'],
title: announcements[index]['name'],
localization: 'Asa Norte, 404 Feira Da Tarde',
price: announcements[index]['price'],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
import 'package:hortum_mobile/data/productor_details_backend.dart';
import 'package:hortum_mobile/views/productor_details/components/announcements_tag.dart';
import 'package:hortum_mobile/views/productor_details/components/productor_localization.dart';
import 'package:hortum_mobile/views/productor_details/services/productor_details_services.dart';

class AnnouncementsDetails extends StatefulWidget {
final ProductorsDetailsApi prodData;
const AnnouncementsDetails({@required this.prodData, Key key})
: super(key: key);

@override
_AnnouncementsDetailsState createState() => _AnnouncementsDetailsState();
}

class _AnnouncementsDetailsState extends State<AnnouncementsDetails> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
width: size.width,
height: size.height * 0.45,
child: ListView(
children: [
Column(
children: [
ProductorLocalization(),
AnnouncementTag(),
ProductorDetaislService.completeAnnouncements(
widget.prodData.announcements)
],
),
],
));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import 'package:flutter/material.dart';

class AnnouncementTag extends StatelessWidget {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Container(
child: Align(
alignment: Alignment.center,
child: Text('Anúncios',
style: TextStyle(
fontFamily: 'Comfortaa-Bold',
fontWeight: FontWeight.bold,
fontSize: size.height * 0.022))),
margin:
EdgeInsets.only(top: size.height * 0.05, bottom: size.height * 0.03),
width: size.width * 0.5,
height: size.height * 0.04,
decoration: BoxDecoration(
color: Color(0xffA7DDB7),
borderRadius: BorderRadius.all(Radius.circular(15))),
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:flutter/material.dart';

class NameActionsWidget extends StatefulWidget {
final String name;

const NameActionsWidget({@required this.name, Key key}) : super(key: key);

@override
_NameActionsWidgetState createState() => _NameActionsWidgetState();
}

class _NameActionsWidgetState extends State<NameActionsWidget> {
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return Padding(
padding: EdgeInsets.only(left: size.width * 0.25),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(widget.name,
style: TextStyle(
fontFamily: 'Roboto-Bold',
fontWeight: FontWeight.bold,
fontSize: 25)),
IconButton(
padding: EdgeInsets.only(left: 10),
icon: Icon(Icons.ios_share, color: Color(0xffA7DDB7)),
onPressed: () {}),
IconButton(
padding: EdgeInsets.only(top: 5, right: 10),
icon: Icon(Icons.report, color: Color(0xffFF4D00)),
onPressed: () {}),
],
),
);
}
}
Loading

0 comments on commit db24bf0

Please sign in to comment.