Skip to content

Commit

Permalink
Merge pull request #20 from gohealthnow/19-tela-de-produto
Browse files Browse the repository at this point in the history
Tela de produto
  • Loading branch information
Polabiel authored Sep 11, 2024
2 parents b86a94c + f79ff4c commit 5e24861
Show file tree
Hide file tree
Showing 9 changed files with 212 additions and 31 deletions.
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
"java.configuration.updateBuildConfiguration": "automatic",
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"node_modules": true
},
"hide-files.files": []
}
1 change: 0 additions & 1 deletion lib/api/layout/pharmacy_view_model.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:gohealth/api/models/pharmacy_model.dart';
import 'package:gohealth/api/repositories/pharmacy_repository.dart';

Expand Down
11 changes: 5 additions & 6 deletions lib/src/app/home/maps/maps_page.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';

import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:geolocator/geolocator.dart';
Expand Down Expand Up @@ -266,7 +265,8 @@ class _MapsPageState extends State<MapsPage> {
mapController: _mapController,
children: [
TileLayer(
urlTemplate: 'http://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga',
urlTemplate:
'http://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga',
userAgentPackageName: 'com.example.gohealth',
),
RichAttributionWidget(
Expand All @@ -285,7 +285,7 @@ class _MapsPageState extends State<MapsPage> {
if (_mylocation != null)
MarkerLayer(markers: [
Marker(
point: _mylocation!,
point: _mylocation!,
width: 40,
height: 40,
child: Container(
Expand All @@ -303,11 +303,10 @@ class _MapsPageState extends State<MapsPage> {
),
child: Icon(
Icons.location_searching_rounded,
color: Colors.green,
color: Colors.green,
size: 25,
),
)
)
))
]),
],
),
Expand Down
40 changes: 40 additions & 0 deletions lib/src/app/sessions/products/description_section.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import 'package:flutter/material.dart';
import 'package:gohealth/api/models/product_models.dart';

class DescriptionWidget extends StatefulWidget {
const DescriptionWidget({Key? key, required this.productModels})
: super(key: key);

@override
State<DescriptionWidget> createState() => DescriptionSectionState();

final ProductModels productModels;
}

class DescriptionSectionState extends State<DescriptionWidget> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
'Descrição',
style: TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
Text(
widget.productModels.description.toString(),
style: TextStyle(fontSize: 16),
),
SizedBox(height: 8),
Text(
'Peso: ${widget.productModels.weight.toString()}g',
style: TextStyle(fontSize: 16),
),
],
),
);
}
}
27 changes: 27 additions & 0 deletions lib/src/app/sessions/products/image_carousel.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import 'package:flutter/material.dart';
import 'package:gohealth/api/models/product_models.dart';

class ImageCarousel extends StatefulWidget {
const ImageCarousel({Key? key, required this.productModels})
: super(key: key);

@override
State<ImageCarousel> createState() => ImageCarouselState();

final ProductModels productModels;
}

class ImageCarouselState extends State<ImageCarousel> {
@override
Widget build(BuildContext context) {
return Container(
height: 200,
child: Column(
children: [
Expanded(
child: Image.network(widget.productModels.image ??
'https://via.placeholder.com/150')),
],
));
}
}
37 changes: 37 additions & 0 deletions lib/src/app/sessions/products/product_details.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import 'package:flutter/material.dart';
import 'package:gohealth/api/models/product_models.dart';

class ProductDetailsPage extends StatefulWidget {
const ProductDetailsPage({Key? key, required this.productModels})
: super(key: key);

@override
State<ProductDetailsPage> createState() => ProductDetails();

final ProductModels productModels;
}


class ProductDetails extends State<ProductDetailsPage> {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.productModels.name ?? 'Nome não disponível',
style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold),
),
SizedBox(height: 8),
Text(
"R\$${widget.productModels.price.toString()}",
style: TextStyle(fontSize: 20, color: Colors.grey),
),
SizedBox(height: 16),
],
),
);
}
}
56 changes: 56 additions & 0 deletions lib/src/app/sessions/products/product_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import 'package:flutter/material.dart';
import 'package:gohealth/api/models/product_models.dart';
import 'image_carousel.dart';
import 'product_details.dart';
import 'description_section.dart';

class ProductPage extends StatefulWidget {
const ProductPage({Key? key, required this.productModels}) : super(key: key);

@override
State<ProductPage> createState() => ProductState();

final ProductModels productModels;
}

class ProductState extends State<ProductPage> {
@override
void initState() {
super.initState();
}

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Produto'),
actions: [
IconButton(
icon: Icon(Icons.more_vert),
onPressed: () {},
),
],
),
body: SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ImageCarousel(productModels: widget.productModels),
ProductDetailsPage(productModels: widget.productModels),
DescriptionWidget(productModels: widget.productModels),
],
),
),
bottomNavigationBar: Padding(
padding: const EdgeInsets.all(16.0),
child: ElevatedButton(
onPressed: () {},
child: Text('Adicionar ao carrinho'),
style: ElevatedButton.styleFrom(
padding: EdgeInsets.symmetric(vertical: 16),
),
),
),
);
}
}
55 changes: 34 additions & 21 deletions lib/src/components/banner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import 'package:gohealth/api/layout/product_view_model.dart';
import 'package:gohealth/api/models/product_models.dart';
import 'package:gohealth/api/repositories/product_repository.dart';

import 'package:gohealth/src/app/sessions/products/product_page.dart';

class BannerComponent extends StatefulWidget {
const BannerComponent({super.key});

Expand Down Expand Up @@ -47,30 +49,41 @@ class _BannerComponentState extends State<BannerComponent> {
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: Column(
children: [
CircleAvatar(
backgroundColor: Colors.primaries[
Random().nextInt(Colors.primaries.length)],
radius: 50,
child: Text(
snapshot.data![index].name!,
style: const TextStyle(
color: Colors.white,
fontSize: 10,
child: GestureDetector(
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
// ! builder: (context) => ProductPage(productId: snapshot.data![index].id),
builder: (context) => ProductPage(
productModels: snapshot.data![index])),
);
},
child: Column(
children: [
CircleAvatar(
backgroundColor: Colors.primaries[
Random().nextInt(Colors.primaries.length)],
radius: 50,
child: Text(
snapshot.data![index].name!,
style: const TextStyle(
color: Colors.white,
fontSize: 10,
),
),
),
),
const SizedBox(height: 5),
Text(
snapshot.data![index].price!.toString(),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
const SizedBox(height: 5),
Text(
snapshot.data![index].price!.toString(),
style: const TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
),
const SizedBox(height: 5),
],
const SizedBox(height: 5),
],
),
),
);
},
Expand Down
4 changes: 2 additions & 2 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -609,10 +609,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
sha256: f652077d0bdf60abe4c1f6377448e8655008eef28f128bc023f7b5e8dfeb48fc
url: "https://pub.dev"
source: hosted
version: "14.2.5"
version: "14.2.4"
web:
dependency: transitive
description:
Expand Down

0 comments on commit 5e24861

Please sign in to comment.