Some relative stuff

This commit is contained in:
2024-05-11 23:27:01 +03:00
parent 57ff8a59e8
commit 75bfc7ea6b
10 changed files with 200 additions and 19 deletions

View File

@@ -35,8 +35,8 @@ class HistoryItemCard extends StatelessWidget {
constraints: const BoxConstraints(
minHeight: 100,
maxHeight: 200,
minWidth: 400,
maxWidth: 600,
minWidth: 600,
maxWidth: 800,
),
child: Card(
elevation: 4,

View File

@@ -14,12 +14,20 @@ class ProductCard extends StatelessWidget {
required this.onTap,
});
double getCardHeight({required BuildContext context}) {
if (MediaQuery.of(context).size.width > 600) {
return 200;
}
return 100;
}
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: onTap,
child: ConstrainedBox(
constraints: const BoxConstraints(minHeight: 200),
constraints: BoxConstraints(
minHeight: 80, maxHeight: getCardHeight(context: context)),
child: Card(
elevation: 3,
color: Theme.of(context).scaffoldBackgroundColor,

View File

@@ -4,6 +4,7 @@ import 'package:gymlink_module_web/components/item_card.dart';
import 'package:gymlink_module_web/pages/basket.dart';
import 'package:gymlink_module_web/pages/detail.dart';
import 'package:gymlink_module_web/pages/order_history.dart';
import 'package:gymlink_module_web/tools/relative.dart';
import 'package:url_launcher/url_launcher.dart';
const List<Map<String, String>> testData = [
@@ -111,9 +112,7 @@ class _MainPageState extends State<MainPage> {
),
),
),
const Spacer(
flex: 2,
),
getSpacer(context: context, flex: 2),
ElevatedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(

View File

@@ -2,36 +2,32 @@ import 'package:flutter/material.dart';
import 'package:gymlink_module_web/components/app_bar.dart';
import 'package:gymlink_module_web/components/heading.dart';
import 'package:gymlink_module_web/components/history_item_card.dart';
import 'package:gymlink_module_web/tools/relative.dart';
List<Map<String, String>> orders = [
{
"image": "product.png",
"price": "120",
"id": "34fa3126-bfaf-5dec-8f4a-b246c097ef73",
"date": "11.09.2001"
},
{"image": "product.png", "price": "120", "id": "66", "date": "11.09.2001"},
{
"image": "product.png",
"price": "150",
"id": "34a26e82-7656-5e98-a44a-c2d01d0b1ad1123",
"id": "56",
"date": "11.09.2001",
},
{
"image": "product.png",
"price": "250",
"id": "4fb204b7-3f9e-52a2-bed1-415c00a31a37123",
"id": "98",
"date": "11.09.2001",
},
{
"image": "product.png",
"price": "300",
"id": "09b2f5bb-683e-5c39-ae89-b8e152fa8bcf123",
"id": "50",
"date": "11.09.2001",
},
{
"image": "product.png",
"price": "100",
"id": "cd1b6817-db94-5394-be1d-af88af79749f123",
"id": "30",
"date": "11.09.2001",
}
];
@@ -40,6 +36,7 @@ class HistoryPage extends StatelessWidget {
const HistoryPage({
super.key,
});
@override
Widget build(BuildContext context) {
return Scaffold(
@@ -69,7 +66,7 @@ class HistoryPage extends StatelessWidget {
},
),
),
const Spacer(),
getSpacer(context: context)
],
),
),

26
lib/pages/order_pay.dart Normal file
View File

@@ -0,0 +1,26 @@
import 'dart:ui_web' as ui;
import 'package:flutter/material.dart';
import 'package:universal_html/html.dart';
class OrderPayPage extends StatelessWidget {
const OrderPayPage({super.key});
@override
Widget build(BuildContext context) {
registerHtmlElementView();
return const HtmlElementView(
viewType: 'payment-html',
);
}
void registerHtmlElementView() {
ui.platformViewRegistry.registerViewFactory(
'payment-html',
(int viewId) => IFrameElement()
..src = 'payment.html'
..style.width = '100%'
..style.height = '500px'
..style.border = 'none');
}
}

View File

@@ -4,9 +4,9 @@ import 'package:gymlink_module_web/pages/main.dart';
import 'package:gymlink_module_web/theme.dart';
class MyAppStateMobile extends State<MyApp> {
bool _isLoading = true;
bool _isLoading = false;
ThemeData theme = myTheme;
bool black_theme = true;
bool black_theme = false;
@override
Widget build(BuildContext context) {

View File

@@ -13,6 +13,7 @@ ThemeData getThemeData(Color color, bool dark) {
).copyWith(
onPrimary: dark ? materialColor[600] : Colors.white,
),
useMaterial3: true,
);
}

11
lib/tools/relative.dart Normal file
View File

@@ -0,0 +1,11 @@
import 'package:flutter/material.dart';
Widget getSpacer(
{required BuildContext context, int flex = 1, double width = 10}) {
if (MediaQuery.of(context).size.width > 600) {
return Spacer(
flex: flex,
);
}
return SizedBox(width: width);
}