Mobile adaptive updates
This commit is contained in:
@@ -24,7 +24,7 @@ if (flutterVersionName == null) {
|
||||
|
||||
android {
|
||||
namespace "com.example.flutter_application_1"
|
||||
compileSdk 34
|
||||
compileSdk flutter.compileSdkVersion
|
||||
ndkVersion flutter.ndkVersion
|
||||
|
||||
compileOptions {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:gymlink_module_web/pages/main.dart';
|
||||
import 'package:gymlink_module_web/main_mobile.dart';
|
||||
import 'package:gymlink_module_web/providers/main.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -73,6 +73,9 @@ class _ExamplePageState extends State<ExamplePage> {
|
||||
super.initState();
|
||||
Future.microtask(
|
||||
() => context.read<GymLinkProvider>().onTokenReceived('token123'));
|
||||
Future.microtask(() => context
|
||||
.read<GymLinkProvider>()
|
||||
.setTheme(ThemeData.dark(useMaterial3: true)));
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -91,9 +94,8 @@ class _ExamplePageState extends State<ExamplePage> {
|
||||
context.read<GymLinkProvider>().onTokenReceived('token123');
|
||||
},
|
||||
),
|
||||
Expanded(
|
||||
child:
|
||||
MainPage(isLoading: context.watch<GymLinkProvider>().isLoading),
|
||||
const Expanded(
|
||||
child: MyApp(),
|
||||
),
|
||||
const SizedBox(
|
||||
height: 20,
|
||||
|
||||
@@ -180,6 +180,21 @@ class _BasketPageState extends State<BasketPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildRowOrCol(
|
||||
{required BuildContext context, required List<Widget> children}) {
|
||||
if (MediaQuery.of(context).size.width > 600) {
|
||||
return Row(children: children);
|
||||
}
|
||||
return Column(children: children);
|
||||
}
|
||||
|
||||
Widget _buildSpacer() {
|
||||
if (MediaQuery.of(context).size.width > 600) {
|
||||
return const Spacer();
|
||||
}
|
||||
return const SizedBox(height: 10);
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
@@ -213,7 +228,8 @@ class _BasketPageState extends State<BasketPage> {
|
||||
),
|
||||
)
|
||||
: Expanded(
|
||||
child: Row(
|
||||
child: _buildRowOrCol(
|
||||
context: context,
|
||||
children: [
|
||||
Expanded(
|
||||
child: ListView.builder(
|
||||
@@ -236,7 +252,7 @@ class _BasketPageState extends State<BasketPage> {
|
||||
},
|
||||
),
|
||||
),
|
||||
const Spacer(),
|
||||
_buildSpacer(),
|
||||
Padding(
|
||||
padding: const EdgeInsetsDirectional.symmetric(
|
||||
horizontal: 10, vertical: 10),
|
||||
|
||||
@@ -41,6 +41,23 @@ class _DetailPageState extends State<DetailPage> {
|
||||
});
|
||||
}
|
||||
|
||||
Widget _buildRowOrCol(
|
||||
{required List<Widget> children,
|
||||
required BuildContext context,
|
||||
MainAxisAlignment mainAxisAlignment = MainAxisAlignment.spaceAround,
|
||||
CrossAxisAlignment crossAxisAlignment = CrossAxisAlignment.center}) {
|
||||
// if (false && MediaQuery.of(context).size.width > 600) {
|
||||
// return Row(
|
||||
// mainAxisAlignment: mainAxisAlignment,
|
||||
// crossAxisAlignment: crossAxisAlignment,
|
||||
// children: children);
|
||||
// }
|
||||
return Column(
|
||||
mainAxisAlignment: mainAxisAlignment,
|
||||
crossAxisAlignment: crossAxisAlignment,
|
||||
children: children);
|
||||
}
|
||||
|
||||
Widget _buildButton() {
|
||||
if (!isInCart) {
|
||||
return ElevatedButton(
|
||||
@@ -100,22 +117,22 @@ class _DetailPageState extends State<DetailPage> {
|
||||
return Scaffold(
|
||||
appBar: const GymLinkAppBar(),
|
||||
body: Column(mainAxisAlignment: MainAxisAlignment.start, children: [
|
||||
GymLinkHeader(title: '${widget.name} - ${widget.id}'),
|
||||
GymLinkHeader(title: widget.name),
|
||||
Expanded(
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(20),
|
||||
child: SizedBox(
|
||||
width: MediaQuery.sizeOf(context).width,
|
||||
height: MediaQuery.sizeOf(context).height,
|
||||
child: Row(
|
||||
// height: MediaQuery.sizeOf(context).height,
|
||||
child: _buildRowOrCol(
|
||||
context: context,
|
||||
mainAxisAlignment: MainAxisAlignment.spaceAround,
|
||||
crossAxisAlignment: CrossAxisAlignment.center,
|
||||
children: [
|
||||
widget.image,
|
||||
Padding(
|
||||
padding:
|
||||
const EdgeInsetsDirectional.fromSTEB(0, 30, 60, 60),
|
||||
padding: const EdgeInsetsDirectional.all(30),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
minWidth: 340,
|
||||
@@ -130,8 +147,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
),
|
||||
child: SingleChildScrollView(
|
||||
child: Padding(
|
||||
padding: const EdgeInsetsDirectional.fromSTEB(
|
||||
20, 15, 10, 15),
|
||||
padding: const EdgeInsetsDirectional.all(15),
|
||||
child: ConstrainedBox(
|
||||
constraints: const BoxConstraints(
|
||||
minHeight: 100,
|
||||
@@ -150,7 +166,7 @@ class _DetailPageState extends State<DetailPage> {
|
||||
alignment: const AlignmentDirectional(0, -1),
|
||||
child: Padding(
|
||||
padding:
|
||||
const EdgeInsetsDirectional.fromSTEB(0, 60, 0, 0),
|
||||
const EdgeInsetsDirectional.fromSTEB(0, 30, 0, 0),
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
|
||||
@@ -20,4 +20,9 @@ class GymLinkProvider with ChangeNotifier {
|
||||
_theme = getThemeData(Color(color), _blackTheme);
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setTheme(ThemeData theme) {
|
||||
_theme = theme;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
16
pubspec.lock
16
pubspec.lock
@@ -216,6 +216,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
nested:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: nested
|
||||
sha256: "03bac4c528c64c95c722ec99280375a6f2fc708eec17c7b3f07253b626cd2a20"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
@@ -264,6 +272,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
provider:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: provider
|
||||
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.1.2"
|
||||
shared_preferences:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
||||
Reference in New Issue
Block a user