package Ġcom . example . android dev challenge Ċ Ċ import Ġandroidx . compose . runtime . derived State Of Ċ import Ġandroidx . compose . runtime . to Mutable State Map Ċ import Ġcom . example . android dev challenge . data . Categories Ċ import Ġcom . example . android dev challenge . data . Repository Ċ import Ġcom . example . android dev challenge . data . Services Ċ import Ġcom . example . android dev challenge . data . model . Service Ċ import Ġcom . example . android dev challenge . data . model . Service Category Ċ import Ġcom . example . android dev challenge . ui . model . Service Category State Ċ import Ġcom . example . android dev challenge . ui . model . Service ListView State Ċ import Ġcom . example . android dev challenge . ui . model . to ListView Presentation Ċ Ċ class ĠService List Presenter Ġ{ ĊĠĠĠ Ġprivate Ġval Ġrepo Ġ= ĠRepository . provided Repository ĊĊĠĠĠ Ġprivate Ġval Ġcategories Ġ= ĠCategories . all Categories . map Ġ{ Ġit Ġto Ġtrue Ġ}. to Mutable State Map () ĊĊĠĠĠ Ġval Ġview State Ġ= Ġderived State Of < Service ListView State > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġservices Ġ= ĠServices . all Services ĊĊĠĠĠĠĠĠĠ ĠService ListView State . Ready ( ĊĠĠĠĠĠĠĠĠĠĠĠ Ġservices . filter By Selected Categories ( categories . toList ()). to ListView Presentation (), ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategories . toList () ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun ĠList < Service >. filter By Selected Categories ( categories : ĠList < Service Category State >) Ġ= ĊĠĠĠĠĠĠĠ Ġfilter Ġ{ Ġservice Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcategories . any Ġ{ Ġ( category , Ġselected ) Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġselected Ġ&& Ġcategory . service Ids . contains ( service . id ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġupdate Category Selection ( category : ĠService Category , Ġchecked : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġcategories . put ( category , Ġchecked ) ĊĠĠĠ Ġ} Ċ }