1919import 'package:easy_localization/easy_localization.dart' ;
2020import 'package:flutter/material.dart' ;
2121import 'package:flutter_svg/svg.dart' ;
22+ import 'package:playground_components/playground_components.dart' ;
2223
2324import '../../../assets/assets.gen.dart' ;
25+ import '../../../constants/sizes.dart' ;
2426import '../state.dart' ;
2527
2628class SolutionButton extends StatelessWidget {
@@ -42,9 +44,69 @@ class SolutionButton extends StatelessWidget {
4244 : null ,
4345 ),
4446 ),
45- onPressed: tourNotifier.toggleShowingSolution,
47+ onPressed: () {
48+ showDialog (
49+ context: context,
50+ builder: (context) => Dialog (
51+ backgroundColor: Colors .transparent,
52+ child: _Popup (tourNotifier: tourNotifier),
53+ ),
54+ );
55+ },
4656 icon: SvgPicture .asset (Assets .svg.solution),
47- label: const Text ('ui.solution' ).tr (),
57+ label: Text (
58+ tourNotifier.isShowingSolution
59+ ? 'pages.tour.assignment'
60+ : 'pages.tour.solution' ,
61+ ).tr (),
62+ ),
63+ );
64+ }
65+ }
66+
67+ class _Popup extends StatelessWidget {
68+ final TourNotifier tourNotifier;
69+
70+ const _Popup ({
71+ required this .tourNotifier,
72+ });
73+
74+ @override
75+ Widget build (BuildContext context) {
76+ return OverlayBody (
77+ child: Container (
78+ width: TobSizes .hintPopupWidth,
79+ padding: const EdgeInsets .all (BeamSizes .size16),
80+ child: Column (
81+ crossAxisAlignment: CrossAxisAlignment .start,
82+ mainAxisSize: MainAxisSize .min,
83+ children: [
84+ Text (
85+ 'pages.tour.solveYourself' ,
86+ style: Theme .of (context).textTheme.headlineMedium,
87+ ).tr (),
88+ const SizedBox (height: BeamSizes .size8),
89+ Row (
90+ mainAxisAlignment: MainAxisAlignment .end,
91+ children: [
92+ TextButton (
93+ onPressed: () {
94+ Navigator .pop (context);
95+ },
96+ child: const Text ('ui.cancel' ).tr (),
97+ ),
98+ const SizedBox (width: BeamSizes .size8),
99+ TextButton (
100+ onPressed: () {
101+ tourNotifier.toggleShowingSolution ();
102+ Navigator .pop (context);
103+ },
104+ child: const Text ('pages.tour.showSolution' ).tr (),
105+ ),
106+ ],
107+ ),
108+ ],
109+ ),
48110 ),
49111 );
50112 }
0 commit comments