Skip to content

Commit ed2ebf5

Browse files
fix: добавление всплывающего окна с информацией о pro-подписке при попытке переключения параметров игры
1 parent 4080f3f commit ed2ebf5

2 files changed

Lines changed: 52 additions & 18 deletions

File tree

frontend/lib/views/components/pro_functions_tooltip.dart

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,26 @@ class ProFunctionsTooltip extends StatefulWidget {
1010
required this.modalHeader,
1111
required this.child,
1212
required this.isPro,
13+
this.controller,
1314
});
1415

1516
final String modalHeader;
1617
final Widget child;
1718
final bool isPro;
19+
final SuperTooltipController? controller;
1820

1921
@override
2022
State<ProFunctionsTooltip> createState() => _ProFunctionsTooltipState();
2123
}
2224

2325
class _ProFunctionsTooltipState extends State<ProFunctionsTooltip> {
24-
final _controller = SuperTooltipController();
26+
late final SuperTooltipController _controller;
27+
28+
@override
29+
void initState() {
30+
super.initState();
31+
_controller = widget.controller ?? SuperTooltipController();
32+
}
2533

2634
@override
2735
Widget build(BuildContext context) {
@@ -38,7 +46,7 @@ class _ProFunctionsTooltipState extends State<ProFunctionsTooltip> {
3846
popupDirection: TooltipDirection.up,
3947
content: DecoratedBox(
4048
decoration: BoxDecoration(
41-
borderRadius: BorderRadius.circular(16), color: Colors.white),
49+
borderRadius: BorderRadius.circular(16), color: Colors.white),
4250
child: Padding(
4351
padding: const EdgeInsets.symmetric(vertical: 24, horizontal: 32),
4452
child: Column(
@@ -62,14 +70,13 @@ class _ProFunctionsTooltipState extends State<ProFunctionsTooltip> {
6270
),
6371
),
6472
),
65-
!widget.isPro
66-
? UpgradeToProButton(
67-
onTap: () {
68-
_controller.hideTooltip();
69-
context.push(RouteLocations.promoScreen);
70-
},
71-
)
72-
: const SizedBox.shrink()
73+
if (!widget.isPro)
74+
UpgradeToProButton(
75+
onTap: () {
76+
_controller.hideTooltip();
77+
context.push(RouteLocations.promoScreen);
78+
},
79+
)
7380
],
7481
),
7582
),

frontend/lib/views/setting_view/components/settings_row.dart

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import "package:flutter/material.dart";
22
import "package:flutter_svg/flutter_svg.dart";
33
import "package:frontend/exports.dart";
44
import "package:provider/provider.dart";
5+
import "package:super_tooltip/super_tooltip.dart";
56

6-
class SettingsRow extends StatelessWidget {
7+
class SettingsRow extends StatefulWidget {
78
const SettingsRow({
89
super.key,
910
this.chose,
@@ -21,8 +22,27 @@ class SettingsRow extends StatelessWidget {
2122
final void Function(bool)? onChanged;
2223
final bool? forceTabletLayout;
2324

25+
@override
26+
State<SettingsRow> createState() => _SettingsRowState();
27+
}
28+
29+
class _SettingsRowState extends State<SettingsRow> {
30+
late final SuperTooltipController _tooltipController;
31+
32+
@override
33+
void initState() {
34+
super.initState();
35+
_tooltipController = SuperTooltipController();
36+
}
37+
38+
@override
39+
void dispose() {
40+
_tooltipController.dispose();
41+
super.dispose();
42+
}
43+
2444
bool _isTablet(BuildContext context) {
25-
return forceTabletLayout ?? MediaQuery.of(context).size.width >= 640;
45+
return widget.forceTabletLayout ?? MediaQuery.of(context).size.width >= 640;
2646
}
2747

2848
@override
@@ -40,7 +60,7 @@ class SettingsRow extends StatelessWidget {
4060
Row(
4161
children: [
4262
Text(
43-
text,
63+
widget.text,
4464
style: TextStyles.body2.copyWith(
4565
color: isPro ? scheme.primary : ColorsConst.disabledColor,
4666
fontSize: isTablet ? 25 : 16,
@@ -51,11 +71,12 @@ class SettingsRow extends StatelessWidget {
5171
),
5272
ProFunctionsTooltip(
5373
isPro: isPro,
54-
modalHeader: modalHeader,
74+
modalHeader: widget.modalHeader,
75+
controller: _tooltipController,
5576
child: SvgPicture.asset(
5677
"assets/images/icons/question_icon.svg",
5778
colorFilter: ColorFilter.mode(
58-
isPro
79+
isPro
5980
? scheme.tertiaryContainer
6081
: ColorsConst.disabledColor,
6182
BlendMode.srcIn),
@@ -67,15 +88,21 @@ class SettingsRow extends StatelessWidget {
6788
data: ThemeData(useMaterial3: false),
6889
child: Switch(
6990
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
70-
value: isPro ? chose! : false,
91+
value: isPro ? widget.chose! : false,
7192
inactiveThumbColor:
7293
isPro ? scheme.surfaceTint : ColorsConst.disabledColor,
7394
inactiveTrackColor: scheme.outline,
7495
activeColor: scheme.inversePrimary,
7596
activeTrackColor: ColorsConst.primaryColor100,
76-
onChanged: onChanged,
97+
onChanged: (value) {
98+
if (isPro) {
99+
widget.onChanged?.call(value);
100+
} else {
101+
_tooltipController.showTooltip();
102+
}
103+
},
77104
),
78-
)
105+
),
79106
],
80107
),
81108
),

0 commit comments

Comments
 (0)