package Ġus . mike and wan . photos . ui . controls . toolbar Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . flow .* Ċ import Ġkotlinx . coroutines . launch Ċ import Ġus . mike and wan . photos . domain . Navigation State Repository Ċ import Ġus . mike and wan . photos . domain . Search Repository Ċ import Ġus . mike and wan . photos . domain . models . Navigation Area Ċ import Ġus . mike and wan . photos . domain . models . Search Request Ċ import Ġus . mike and wan . photos . domain . models . Search Source Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠToolbar ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġnavigation State Repository : ĠNavigation State Repository , ĊĠĠĠ Ġprivate Ġval Ġsearch Repository : ĠSearch Repository , Ċ ): ĠViewModel () Ġ{ ĊĠĠĠ Ġval Ġshow App Icon Ġ= Ġnavigation State Repository . enable Drawer ĊĠĠĠ Ġval Ġtoolbar Title Ġ= Ġnavigation State Repository . toolbar Title ĊĊĠĠĠ Ġprivate Ġval Ġ_ close Keyboard Signal Ġ= ĠMutable State Flow ( false ) ĊĠĠĠ Ġval Ġclose Keyboard Signal Ġ= Ġ_ close Keyboard Signal . as State Flow () ĊĊĠĠĠ Ġval Ġshow Search Ġ= Ġnavigation State Repository ĊĠĠĠĠĠĠĠ Ġ. nav Area ĊĠĠĠĠĠĠĠ Ġ. map Ġ{ Ġit Ġ== ĠNavigation Area . Search Ġ} ĊĠĠĠĠĠĠĠ Ġ. state In ( viewModel Scope , ĠSh aring Started . E ager ly , Ġfalse ) ĊĊĠĠĠ Ġval Ġsearch Request Ġ= Ġsearch Repository ĊĠĠĠĠĠĠĠ Ġ. search Request ĊĠĠĠĠĠĠĠ Ġ. state In ( viewModel Scope , ĠSh aring Started . E ager ly , ĠSearch Request ("", ĠSearch Source . None )) ĊĊĠĠĠ Ġfun Ġon App Icon Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġnavigation State Repository . request Nav Drawer Open () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon Back Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġnavigation State Repository . request Navigate Back () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġsearch ( query : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ close Keyboard Signal . value Ġ= Ġtrue ĊĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġsearch Repository ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. perform Search ( query , ĠSearch Source . QueryInterface ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. collect Ġ{ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġclose Keyboard Signal Handled () Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ close Keyboard Signal . value Ġ= Ġfalse ĊĠĠĠ Ġ} Ċ }