Compare commits

...

2 Commits

Author SHA1 Message Date
73fe273c75 Fix: some changes 2024-06-14 01:37:54 +03:00
f5e1407281 Fix: https url 2024-06-14 01:37:42 +03:00
10 changed files with 59 additions and 35 deletions

View File

@@ -6,7 +6,7 @@ class BasketItemCard extends StatelessWidget {
final String name;
final String price;
final String id;
final Image image;
final Widget image;
final String quantity;
final VoidCallback onTapPlus;
final VoidCallback onTapMinus;

View File

@@ -1,7 +1,7 @@
import 'package:flutter/material.dart';
class ProductCard extends StatelessWidget {
final Image imagePath;
final Widget imagePath;
final String name;
final String price;
final VoidCallback onTap;

View File

@@ -5,7 +5,7 @@ class OrderConfirmItemCard extends StatelessWidget {
final String name;
final int count;
final double price;
final Image image;
final Widget image;
const OrderConfirmItemCard({
super.key,

View File

@@ -12,8 +12,7 @@ void main() {
}
Future<String> getToken(String token, String clientId) async {
debugPrint(token);
var url = Uri.http('gymlink.freemyip.com:8080', 'api/auth/authorize_client');
var url = Uri.https('gymlink.freemyip.com', 'api/auth/authorize_client');
try {
var response = await http.post(url,
body: {'GymKey': token, 'id': clientId}); // Just testing token

View File

@@ -283,9 +283,22 @@ class _BasketPageState extends State<BasketPage> {
name: shortString(item.title),
price: item.price.toStringAsFixed(2),
id: item.id,
image: Image(
image: NetworkImage(item.images[0].url),
width: 50,
image: FutureBuilder(
future: precacheImage(
NetworkImage(item.images[0].url),
context),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.done) {
return Image(
image: NetworkImage(
item.images[0].url),
width: 50,
);
} else {
return const CircularProgressIndicator();
}
},
),
onTapPlus: () =>
addItem(item.id.toString()),

View File

@@ -53,7 +53,7 @@ class _DetailPageState extends State<DetailPage> {
Future<void> _getItem() async {
final Uri url =
Uri.http('gymlink.freemyip.com:8080', 'api/product/get/${widget.id}');
Uri.https('gymlink.freemyip.com', 'api/product/get/${widget.id}');
final response = await http.get(url, headers: {
'Authorization': 'Bearer ${context.read<GymLinkProvider>().token}',
});

View File

@@ -111,7 +111,6 @@ class _MainPageState extends State<MainPage> {
setState(() {
filteredData = data;
itemViewCount = min(filteredData.length, 5);
debugPrint(itemViewCount.toString());
});
WidgetsBinding.instance.addPostFrameCallback((_) {
for (var element in filteredData.sublist(0, itemViewCount)) {
@@ -281,11 +280,22 @@ class _MainPageState extends State<MainPage> {
itemBuilder: (context, index) {
final product = filteredData[index];
return ProductCard(
imagePath: Image(
image:
Image.network(product.images[0].url)
.image,
width: 120,
imagePath: FutureBuilder(
future: precacheImage(
NetworkImage(product.images[0].url),
context),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.done) {
return Image(
image: NetworkImage(
product.images[0].url),
width: 120,
);
} else {
return const CircularProgressIndicator();
}
},
),
name: shortString(product.title),
price: product.price.toStringAsFixed(2),

View File

@@ -87,7 +87,7 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
}
Future<void> _goToPage() async {
final Uri url = Uri.parse('https://google.com');
final Uri url = Uri.parse('https://example.org');
if (!await launchUrl(url, webOnlyWindowName: '_blank')) {
throw 'Could not launch $url';
}
@@ -115,10 +115,22 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
final item = cartItems[index];
return OrderConfirmItemCard(
name: shortString(item.title),
image: Image(
image: NetworkImage(item.images[0].url),
width: 50,
height: 50),
image: FutureBuilder(
future: precacheImage(
NetworkImage(item.images[0].url), context),
builder: (context, snapshot) {
if (snapshot.connectionState ==
ConnectionState.done) {
return Image(
image: NetworkImage(item.images[0].url),
width: 50,
height: 50,
);
} else {
return const CircularProgressIndicator();
}
},
),
price: item.price,
count: item.localCount,
);
@@ -165,15 +177,6 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
),
),
),
CheckboxListTile(
title: const Text('Согласен с обаботкой персональных данных'),
value: isAgree,
onChanged: (value) {
setState(() {
isAgree = value!;
});
},
),
ElevatedButton(
onPressed: () async {
_goToPage();

View File

@@ -10,8 +10,7 @@ Future<List<GymItem>> getItems(BuildContext context,
{String searchText = '', String categoryId = ''}) async {
final token = context.read<GymLinkProvider>().token;
if (token != '') {
final Uri url =
Uri.http('gymlink.freemyip.com:8080', 'api/product/get-list');
final Uri url = Uri.https('gymlink.freemyip.com', 'api/product/get-list');
try {
final response = await http.post(url,
headers: {
@@ -48,7 +47,7 @@ Future<List<GymItem>> getItemsByIds(
return [];
}
final Uri url =
Uri.http('gymlink.freemyip.com:8080', 'api/product/get-products');
Uri.https('gymlink.freemyip.com', 'api/product/get-products');
try {
final response = await http.post(url,
headers: {
@@ -76,8 +75,8 @@ Future<List<GymItem>> getItemsByIds(
Future<List<GymCategory>> getCategories(BuildContext context) async {
final token = context.read<GymLinkProvider>().token;
if (token != '') {
final Uri url = Uri.http(
'gymlink.freemyip.com:8080', 'api/category/get-internal-categories');
final Uri url = Uri.https(
'gymlink.freemyip.com', 'api/category/get-internal-categories');
try {
final response = await http.get(url, headers: {
'Authorization': 'Bearer $token',

View File

@@ -8,7 +8,7 @@
let appState = window._appState;
function getToken(token) {
fetch('http://gymlink.freemyip.com:8080/api/auth/authorize_client', {
fetch('https://gymlink.freemyip.com/api/auth/authorize_client', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({