@@ -34,6 +34,8 @@ type Msg
3434 | ShowCipherPage Bridge.Sub_LoadCipher
3535 | RequestCipher CipherId
3636 | PopView
37+ | ToggleMenu
38+ | ChangeFilter CipherFilter
3739
3840
3941type alias CipherId =
@@ -43,6 +45,9 @@ type alias CipherId =
4345type alias Model =
4446 { notifications : List Notification.Config
4547 , pageStack : Navigation.PageStack PageModel
48+ , menuShown : Bool
49+ , email : Maybe String
50+ , filter : CipherFilter
4651 }
4752
4853
@@ -132,27 +137,77 @@ subscriptions _ =
132137 )
133138
134139
140+type CipherFilter
141+ = AnyCipher
142+ | Specific Bridge.Sub_LoadCiphers_cipherType
143+
144+
145+applyCipherFilter : CipherFilter -> Bridge.Sub_LoadCiphers_List -> Bridge.Sub_LoadCiphers_List
146+applyCipherFilter filter list =
147+ case filter of
148+ AnyCipher ->
149+ list
150+
151+ Specific t ->
152+ list |> List.filter (.cipherType >> (==) t)
153+
154+
135155init : ( Model, Cmd Msg )
136156init =
137157 ( { notifications = []
138158 , pageStack = Nonempty.singleton LoadingPage
159+ , menuShown = False
160+ , email = Nothing
161+ , filter = AnyCipher
139162 }
140163 , FFI.sendBridge Bridge.Init
141164 )
142165
143166
167+pageShouldShowMenu : PageModel -> Bool
168+pageShouldShowMenu page =
169+ case page of
170+ CiphersModel _ ->
171+ True
172+
173+ _ ->
174+ False
175+
176+
144177view : Model -> Html Msg
145178view model =
146− Navigation.showNavigationView { popStack = PopView }
179+ Navigation.showNavigationView
180+ { popStack = PopView
181+ , toggleMenu = ToggleMenu
182+ }
147183 model.pageStack
148184 (\page ->
149185 let
150186 ( title, body ) =
151− showPage page
187+ case page of
188+ CiphersModel m ->
189+ CiphersModel { m | ciphers = m.ciphers |> applyCipherFilter model.filter }
190+ |> showPage
191+
192+ _ ->
193+ showPage page
152194 in
153− ( title
154− , maybeList (List.head model.notifications) (Notification.notification CloseNotification) ++ body
155− )
195+ { title = title
196+ , body = maybeList (List.head model.notifications) (Notification.notification CloseNotification) ++ body
197+ , menuConfig =
198+ if pageShouldShowMenu page && model.menuShown then
199+ Just
200+ { title = Maybe.withDefault "" model.email
201+ , items =
202+ [ { icons = "", name = "", trigger = ChangeFilter AnyCipher }
203+ ]
204+ , close = ToggleMenu
205+ }
206+
207+ else
208+ Nothing
209+ , menuPossible = pageShouldShowMenu page
210+ }
156211 )
157212
158213
@@ -302,6 +357,9 @@ update msg model =
302357 , Cmd.none
303358 )
304359
360+ ToggleMenu ->
361+ ( { model | menuShown = not model.menuShown }, Cmd.none )
362+
305363
306364loginCallbacks : Login.Callbacks Msg
307365loginCallbacks =