Compare commits
2 Commits
27da063c34
...
73fe273c75
| Author | SHA1 | Date | |
|---|---|---|---|
| 73fe273c75 | |||
| f5e1407281 |
@@ -6,7 +6,7 @@ class BasketItemCard extends StatelessWidget {
|
|||||||
final String name;
|
final String name;
|
||||||
final String price;
|
final String price;
|
||||||
final String id;
|
final String id;
|
||||||
final Image image;
|
final Widget image;
|
||||||
final String quantity;
|
final String quantity;
|
||||||
final VoidCallback onTapPlus;
|
final VoidCallback onTapPlus;
|
||||||
final VoidCallback onTapMinus;
|
final VoidCallback onTapMinus;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class ProductCard extends StatelessWidget {
|
class ProductCard extends StatelessWidget {
|
||||||
final Image imagePath;
|
final Widget imagePath;
|
||||||
final String name;
|
final String name;
|
||||||
final String price;
|
final String price;
|
||||||
final VoidCallback onTap;
|
final VoidCallback onTap;
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class OrderConfirmItemCard extends StatelessWidget {
|
|||||||
final String name;
|
final String name;
|
||||||
final int count;
|
final int count;
|
||||||
final double price;
|
final double price;
|
||||||
final Image image;
|
final Widget image;
|
||||||
|
|
||||||
const OrderConfirmItemCard({
|
const OrderConfirmItemCard({
|
||||||
super.key,
|
super.key,
|
||||||
|
|||||||
@@ -12,8 +12,7 @@ void main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getToken(String token, String clientId) async {
|
Future<String> getToken(String token, String clientId) async {
|
||||||
debugPrint(token);
|
var url = Uri.https('gymlink.freemyip.com', 'api/auth/authorize_client');
|
||||||
var url = Uri.http('gymlink.freemyip.com:8080', 'api/auth/authorize_client');
|
|
||||||
try {
|
try {
|
||||||
var response = await http.post(url,
|
var response = await http.post(url,
|
||||||
body: {'GymKey': token, 'id': clientId}); // Just testing token
|
body: {'GymKey': token, 'id': clientId}); // Just testing token
|
||||||
|
|||||||
@@ -283,9 +283,22 @@ class _BasketPageState extends State<BasketPage> {
|
|||||||
name: shortString(item.title),
|
name: shortString(item.title),
|
||||||
price: item.price.toStringAsFixed(2),
|
price: item.price.toStringAsFixed(2),
|
||||||
id: item.id,
|
id: item.id,
|
||||||
image: Image(
|
image: FutureBuilder(
|
||||||
image: NetworkImage(item.images[0].url),
|
future: precacheImage(
|
||||||
width: 50,
|
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: () =>
|
onTapPlus: () =>
|
||||||
addItem(item.id.toString()),
|
addItem(item.id.toString()),
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class _DetailPageState extends State<DetailPage> {
|
|||||||
|
|
||||||
Future<void> _getItem() async {
|
Future<void> _getItem() async {
|
||||||
final Uri url =
|
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: {
|
final response = await http.get(url, headers: {
|
||||||
'Authorization': 'Bearer ${context.read<GymLinkProvider>().token}',
|
'Authorization': 'Bearer ${context.read<GymLinkProvider>().token}',
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -111,7 +111,6 @@ class _MainPageState extends State<MainPage> {
|
|||||||
setState(() {
|
setState(() {
|
||||||
filteredData = data;
|
filteredData = data;
|
||||||
itemViewCount = min(filteredData.length, 5);
|
itemViewCount = min(filteredData.length, 5);
|
||||||
debugPrint(itemViewCount.toString());
|
|
||||||
});
|
});
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||||
for (var element in filteredData.sublist(0, itemViewCount)) {
|
for (var element in filteredData.sublist(0, itemViewCount)) {
|
||||||
@@ -281,11 +280,22 @@ class _MainPageState extends State<MainPage> {
|
|||||||
itemBuilder: (context, index) {
|
itemBuilder: (context, index) {
|
||||||
final product = filteredData[index];
|
final product = filteredData[index];
|
||||||
return ProductCard(
|
return ProductCard(
|
||||||
imagePath: Image(
|
imagePath: FutureBuilder(
|
||||||
image:
|
future: precacheImage(
|
||||||
Image.network(product.images[0].url)
|
NetworkImage(product.images[0].url),
|
||||||
.image,
|
context),
|
||||||
width: 120,
|
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),
|
name: shortString(product.title),
|
||||||
price: product.price.toStringAsFixed(2),
|
price: product.price.toStringAsFixed(2),
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _goToPage() async {
|
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')) {
|
if (!await launchUrl(url, webOnlyWindowName: '_blank')) {
|
||||||
throw 'Could not launch $url';
|
throw 'Could not launch $url';
|
||||||
}
|
}
|
||||||
@@ -115,10 +115,22 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
final item = cartItems[index];
|
final item = cartItems[index];
|
||||||
return OrderConfirmItemCard(
|
return OrderConfirmItemCard(
|
||||||
name: shortString(item.title),
|
name: shortString(item.title),
|
||||||
image: Image(
|
image: FutureBuilder(
|
||||||
image: NetworkImage(item.images[0].url),
|
future: precacheImage(
|
||||||
width: 50,
|
NetworkImage(item.images[0].url), context),
|
||||||
height: 50),
|
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,
|
price: item.price,
|
||||||
count: item.localCount,
|
count: item.localCount,
|
||||||
);
|
);
|
||||||
@@ -165,15 +177,6 @@ class _OrderConfirmationPageState extends State<OrderConfirmationPage> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
CheckboxListTile(
|
|
||||||
title: const Text('Согласен с обаботкой персональных данных'),
|
|
||||||
value: isAgree,
|
|
||||||
onChanged: (value) {
|
|
||||||
setState(() {
|
|
||||||
isAgree = value!;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
),
|
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
_goToPage();
|
_goToPage();
|
||||||
|
|||||||
@@ -10,8 +10,7 @@ Future<List<GymItem>> getItems(BuildContext context,
|
|||||||
{String searchText = '', String categoryId = ''}) async {
|
{String searchText = '', String categoryId = ''}) async {
|
||||||
final token = context.read<GymLinkProvider>().token;
|
final token = context.read<GymLinkProvider>().token;
|
||||||
if (token != '') {
|
if (token != '') {
|
||||||
final Uri url =
|
final Uri url = Uri.https('gymlink.freemyip.com', 'api/product/get-list');
|
||||||
Uri.http('gymlink.freemyip.com:8080', 'api/product/get-list');
|
|
||||||
try {
|
try {
|
||||||
final response = await http.post(url,
|
final response = await http.post(url,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -48,7 +47,7 @@ Future<List<GymItem>> getItemsByIds(
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
final Uri url =
|
final Uri url =
|
||||||
Uri.http('gymlink.freemyip.com:8080', 'api/product/get-products');
|
Uri.https('gymlink.freemyip.com', 'api/product/get-products');
|
||||||
try {
|
try {
|
||||||
final response = await http.post(url,
|
final response = await http.post(url,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -76,8 +75,8 @@ Future<List<GymItem>> getItemsByIds(
|
|||||||
Future<List<GymCategory>> getCategories(BuildContext context) async {
|
Future<List<GymCategory>> getCategories(BuildContext context) async {
|
||||||
final token = context.read<GymLinkProvider>().token;
|
final token = context.read<GymLinkProvider>().token;
|
||||||
if (token != '') {
|
if (token != '') {
|
||||||
final Uri url = Uri.http(
|
final Uri url = Uri.https(
|
||||||
'gymlink.freemyip.com:8080', 'api/category/get-internal-categories');
|
'gymlink.freemyip.com', 'api/category/get-internal-categories');
|
||||||
try {
|
try {
|
||||||
final response = await http.get(url, headers: {
|
final response = await http.get(url, headers: {
|
||||||
'Authorization': 'Bearer $token',
|
'Authorization': 'Bearer $token',
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
let appState = window._appState;
|
let appState = window._appState;
|
||||||
|
|
||||||
function getToken(token) {
|
function getToken(token) {
|
||||||
fetch('http://gymlink.freemyip.com:8080/api/auth/authorize_client', {
|
fetch('https://gymlink.freemyip.com/api/auth/authorize_client', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
|||||||
Reference in New Issue
Block a user