Skip to content

Commit d70f3f9

Browse files
committed
fix: исправлена ошибка, приводящая к наслаиванию адаптивных экранов друг на друга на главном экране
1 parent a6f7a52 commit d70f3f9

4 files changed

Lines changed: 26 additions & 111 deletions

File tree

frontend/lib/views/game_view/components/shared_functions.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import 'package:flutter/material.dart';
21
import 'package:intl/intl.dart';
32
import 'package:sqflite/sqflite.dart';
43
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

frontend/lib/views/menu_view/menu_page_view.dart

Lines changed: 2 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import "package:flutter/material.dart";
22
import "package:go_router/go_router.dart";
33
import "package:provider/provider.dart";
44
import "../../exports.dart";
5-
import "package:flutter_gen/gen_l10n/app_localizations.dart";
65
import '../menu_view/phone_menu_layout.dart';
76
import '../menu_view/tablet_menu_layout.dart';
87

@@ -23,23 +22,15 @@ class _MyMenuViewState extends State<MyMenuView> {
2322

2423
@override
2524
Widget build(BuildContext context) {
26-
final provider = Provider.of<ThemeProvider>(context, listen: false);
27-
final scheme = Theme.of(context).colorScheme;
28-
final width = MediaQuery.of(context).size.width;
29-
final height = MediaQuery.of(context).size.height;
30-
final aspectRatio = MediaQuery.of(context).size.aspectRatio;
31-
final l10n = AppLocalizations.of(context)!;
32-
3325
return Scaffold(
34-
backgroundColor: scheme.background,
26+
backgroundColor: Theme.of(context).colorScheme.background,
3527
body: Consumer<GameModel>(
3628
builder: (context, gameModel, child) {
3729
return SafeArea(
3830
child: LayoutBuilder(
3931
builder: (context, constraints) {
4032
final isTablet = constraints.maxWidth >= 640;
4133
final size = Size(constraints.maxWidth, constraints.maxHeight);
42-
4334
final menuView = isTablet
4435
? TabletMenuView(
4536
gameModel: gameModel,
@@ -49,64 +40,7 @@ class _MyMenuViewState extends State<MyMenuView> {
4940
gameModel: gameModel,
5041
size: size,
5142
);
52-
53-
return Column(
54-
children: [
55-
Expanded(child: menuView),
56-
SizedBox(height: height * 0.04),
57-
Padding(
58-
padding: aspectRatio < 0.65
59-
? EdgeInsets.zero
60-
: const EdgeInsets.only(left: 15),
61-
child: ConstrainedBox(
62-
constraints: BoxConstraints(maxHeight: height * 0.2),
63-
child: FittedBox(
64-
child: Text(
65-
aspectRatio < 0.65 ? l10n.slogan : l10n.sloganWide,
66-
style: TextStyles.title1.copyWith(
67-
color: scheme.primary,
68-
),
69-
),
70-
),
71-
),
72-
),
73-
Expanded(
74-
child: Padding(
75-
padding: aspectRatio < 0.65
76-
? EdgeInsets.zero
77-
: EdgeInsets.only(
78-
top: height * 0.1,
79-
left: width * 0.15,
80-
right: width * 0.05,
81-
bottom: height * 0.03),
82-
child: SvgPicture.asset(
83-
alignment: Alignment.bottomRight,
84-
width: double.infinity,
85-
"${MenuPageStringConst.pathToIcon}pieces.svg",
86-
),
87-
),
88-
),
89-
Align(
90-
alignment: Alignment.bottomCenter,
91-
child: Padding(
92-
padding: const EdgeInsets.only(bottom: 20),
93-
child: ConstrainedBox(
94-
constraints: BoxConstraints(maxHeight: height * 0.08),
95-
child: NextPageButton(
96-
text: l10n.startGameButton,
97-
textColor: ColorsConst.primaryColor0,
98-
buttonColor: scheme.secondaryContainer,
99-
isClickable: true,
100-
onTap: () {
101-
context.go(RouteLocations.settingsScreen,
102-
extra: gameModel);
103-
},
104-
),
105-
),
106-
),
107-
),
108-
],
109-
);
43+
return menuView;
11044
},
11145
),
11246
);

frontend/lib/views/menu_view/phone_menu_layout.dart

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "package:flutter_svg/svg.dart";
33
import "../../exports.dart";
44
import '../menu_view/components/menu_app_bar.dart';
55
import '../menu_view/components/menu_button.dart';
6+
import "package:flutter_gen/gen_l10n/app_localizations.dart";
67

78
class PhoneMenuView extends StatelessWidget {
89
final GameModel gameModel;
@@ -18,8 +19,8 @@ class PhoneMenuView extends StatelessWidget {
1819
Widget build(BuildContext context) {
1920
final width = MediaQuery.of(context).size.width;
2021
final height = MediaQuery.of(context).size.height;
21-
final bool isTablet = MediaQuery.of(context).size.aspectRatio < 0.65;
2222
final colorScheme = Theme.of(context).colorScheme;
23+
final l10n = AppLocalizations.of(context)!;
2324

2425
return ConstrainedBox(
2526
constraints: BoxConstraints(minWidth: width, minHeight: height),
@@ -36,16 +37,12 @@ class PhoneMenuView extends StatelessWidget {
3637
),
3738
SizedBox(height: height * 0.04),
3839
Padding(
39-
padding: isTablet
40-
? EdgeInsets.zero
41-
: const EdgeInsets.only(left: 15),
40+
padding: const EdgeInsets.only(left: 15),
4241
child: ConstrainedBox(
4342
constraints: BoxConstraints(maxHeight: height * 0.2),
4443
child: FittedBox(
4544
child: Text(
46-
isTablet
47-
? MenuPageStringConst.slogan
48-
: MenuPageStringConst.sloganWide,
45+
l10n.slogan,
4946
style: TextStyles.title1.copyWith(
5047
color: colorScheme.primary,
5148
),
@@ -54,25 +51,16 @@ class PhoneMenuView extends StatelessWidget {
5451
),
5552
),
5653
Expanded(
57-
child: Padding(
58-
padding: isTablet
59-
? EdgeInsets.zero
60-
: EdgeInsets.only(
61-
top: height * 0.1,
62-
left: width * 0.15,
63-
right: width * 0.05,
64-
bottom: height * 0.03),
65-
child: SvgPicture.asset(
66-
alignment: Alignment.bottomRight,
67-
width: double.infinity,
68-
"${MenuPageStringConst.pathToIcon}pieces.svg",
69-
),
54+
child: SvgPicture.asset(
55+
alignment: Alignment.bottomRight,
56+
width: double.infinity,
57+
"${MenuPageStringConst.pathToIcon}pieces.svg",
7058
),
7159
),
7260
MenuButton(
7361
gameModel: gameModel,
7462
height: height,
75-
buttonText: MenuPageStringConst.localButton,
63+
buttonText: l10n.startGame,
7664
settingsScreenRoute: RouteLocations.settingsScreen,
7765
),
7866
],

frontend/lib/views/menu_view/tablet_menu_layout.dart

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import "package:flutter_svg/svg.dart";
33
import "../../exports.dart";
44
import '../menu_view/components/menu_app_bar.dart';
55
import '../menu_view/components/menu_button.dart';
6+
import "package:flutter_gen/gen_l10n/app_localizations.dart";
67

78
class TabletMenuView extends StatelessWidget {
89
final GameModel gameModel;
@@ -18,8 +19,8 @@ class TabletMenuView extends StatelessWidget {
1819
Widget build(BuildContext context) {
1920
final width = MediaQuery.of(context).size.width;
2021
final height = MediaQuery.of(context).size.height;
21-
final bool isTablet = MediaQuery.of(context).size.aspectRatio < 0.65;
2222
final colorScheme = Theme.of(context).colorScheme;
23+
final l10n = AppLocalizations.of(context)!;
2324

2425
return ConstrainedBox(
2526
constraints: BoxConstraints(minWidth: width, minHeight: height),
@@ -37,26 +38,19 @@ class TabletMenuView extends StatelessWidget {
3738
guidebookScreenRoute: RouteLocations.guidebookScreen,
3839
),
3940
SizedBox(height: height * 0.04),
40-
Padding(
41-
padding: isTablet
42-
? EdgeInsets.zero
43-
: const EdgeInsets.only(left: 15),
44-
child: ConstrainedBox(
45-
constraints: BoxConstraints(
46-
maxHeight: height * 0.2,
47-
maxWidth: width * 0.8,
48-
),
49-
child: FittedBox(
50-
fit: BoxFit.scaleDown,
51-
alignment: Alignment.centerLeft,
52-
child: Text(
53-
isTablet
54-
? MenuPageStringConst.slogan
55-
: MenuPageStringConst.sloganWide,
56-
style: TextStyles.title1.copyWith(
57-
color: colorScheme.primary,
58-
fontSize: TextStyles.title1.fontSize! * 1.9,
59-
),
41+
ConstrainedBox(
42+
constraints: BoxConstraints(
43+
maxHeight: height * 0.2,
44+
maxWidth: width * 0.8,
45+
),
46+
child: FittedBox(
47+
fit: BoxFit.scaleDown,
48+
alignment: Alignment.centerLeft,
49+
child: Text(
50+
l10n.sloganWide,
51+
style: TextStyles.title1.copyWith(
52+
color: colorScheme.primary,
53+
fontSize: TextStyles.title1.fontSize! * 1.9,
6054
),
6155
),
6256
),

0 commit comments

Comments
 (0)