@@ -2,6 +2,7 @@ module Main.View exposing (render)
22
33import Element exposing (..)
44import Element.Background as Background
5+ import Element.Border as Border
56import Element.Font as Font
67import Html exposing (Html )
78import Main.Model exposing (Model , Stage (..) )
@@ -13,10 +14,12 @@ import Stages.Finished.View
1314import Stages.Intro.View
1415import Utils.Colors as Colors
1516import Utils.Constants as Constants
17+ import Utils.Types.BrokenFile exposing (BrokenFile )
18+ import Utils.UI.Buttons as Buttons
1619
1720
1821render : Model -> { title : String , body : List (Html Msg ) }
19- render { requestedBugCount , stage , maybeError, logo } =
22+ render ( { maybeError } as model ) =
2023 { title = Constants . appName
2124 , body =
2225 [ layout
@@ -41,32 +44,94 @@ render { requestedBugCount, stage, maybeError, logo } =
4144 none
4245 )
4346 ]
44- <|
45- case stage of
46- Intro ->
47- Stages . Intro . View . render logo
47+ ( renderViewByStage model )
48+ ]
49+ }
50+
4851
49- ChooseFile { startType, status } ->
50- Element . map ChooseFileInterface <|
51- Stages . ChooseFile . View . render
52- { requestedBugCount = requestedBugCount
53- , startType = startType
54- , status = status
55- }
52+ exitMenu : BrokenFile -> Element Msg
53+ exitMenu brokenFile =
54+ column
55+ [ centerX
56+ , centerY
57+ , spacing 40
58+ , paddingXY 40 0
59+ , Font . center
60+ ]
61+ [ paragraph [ Font . size 30 ] [ text " Quit Menu" ]
62+ , paragraph []
63+ [ text " You pressed the \" quit\" shortcut before resetting the broken file. "
64+ , redText
65+ ( " If you quit without resetting the file, "
66+ ++ Constants . appName
67+ ++ " will not be able to remove any bugs that are still in the file. What do you want to do?"
68+ )
69+ ]
70+ , column [ spacing 15 , centerX ]
71+ [ Buttons . button [ centerX, width ( px 320 ) , Background . color Colors . green ]
72+ { name = " quit and reset the file"
73+ , msg = QuitAndResetFile brokenFile
74+ }
75+ , Buttons . button [ centerX, width ( px 320 ) , Background . color Colors . red ]
76+ { name = " quit without resetting the file"
77+ , msg = Quit
78+ }
79+ , Buttons . button [ centerX, width ( px 320 ) ]
80+ { name = " go back"
81+ , msg = CancelQuitRequest
82+ }
83+ ]
84+ , paragraph [ Font . center, centerX, width ( px 450 ) ]
85+ [ text " You can also "
86+ , redText " press the \" quit\" shortcut one more time to quit without resetting the file."
87+ ]
88+ ]
5689
57- Debugging { brokenFile, currentPage, currentHelpTab, encouragements, currentDebuggingTip } ->
58- Element . map DebuggingInterface <|
59- Stages . Debugging . View . render
60- { requestedBugCount = requestedBugCount
61- , encouragements = encouragements
62- , brokenFile = brokenFile
63- , currentPage = currentPage
64- , currentHelpTab = currentHelpTab
65- , currentDebuggingTip = currentDebuggingTip
66- }
6790
68- Finished finishModel ->
69- Element . map FinishedInterface <|
70- Stages . Finished . View . render finishModel
91+ redText : String -> Element msg
92+ redText content =
93+ el
94+ [ Background . color Colors . red
95+ , Font . color Colors . white
96+ , paddingXY 7 3
97+ , Border . rounded 4
7198 ]
72- }
99+ ( text content)
100+
101+
102+ renderViewByStage : Model -> Element Msg
103+ renderViewByStage { requestedBugCount, stage, showExitMenu, logo } =
104+ case stage of
105+ Intro ->
106+ Stages . Intro . View . render logo
107+
108+ ChooseFile { startType, status } ->
109+ Element . map ChooseFileInterface <|
110+ Stages . ChooseFile . View . render
111+ { requestedBugCount = requestedBugCount
112+ , startType = startType
113+ , status = status
114+ }
115+
116+ Debugging { brokenFile, currentPage, currentHelpTab, encouragements, currentDebuggingTip } ->
117+ if showExitMenu then
118+ exitMenu brokenFile
119+
120+ else
121+ Element . map DebuggingInterface <|
122+ Stages . Debugging . View . render
123+ { requestedBugCount = requestedBugCount
124+ , encouragements = encouragements
125+ , brokenFile = brokenFile
126+ , currentPage = currentPage
127+ , currentHelpTab = currentHelpTab
128+ , currentDebuggingTip = currentDebuggingTip
129+ }
130+
131+ Finished ( { brokenFile } as finishModel) ->
132+ if showExitMenu then
133+ exitMenu brokenFile
134+
135+ else
136+ Element . map FinishedInterface <|
137+ Stages . Finished . View . render finishModel
0 commit comments