package Ġcom . a ith an as ak is . channels list Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . a ith an as ak is . channels list . data . models . Channel Ċ import Ġcom . a ith an as ak is . channels list . data . models . static Channels List Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . State Flow Ċ Ċ sealed Ġclass ĠMain Ui Events Ġ{ ĊĠĠĠ Ġclass ĠChannel Clicked ( val Ġchannel : ĠChannel ) Ġ: ĠMain Ui Events () ĊĠĠĠ Ġobject ĠNo Event Ġ: ĠMain Ui Events () Ċ } Ċ Ċ data Ġclass ĠChannels List State ( val Ġchannels : ĠList < Channel >) Ċ Ċ class ĠMain ViewModel Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġfocused Channel : ĠChannel ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġval Ġ_ ui Events Flow Ġ= ĠMutable State Flow < Main Ui Events >( Main Ui Events . No Event ) ĊĠĠĠ Ġval Ġui Events Flow : ĠState Flow < Main Ui Events > Ġ= Ġ_ ui Events Flow ĊĊĠĠĠ Ġprivate Ġval Ġ_ channels Flow Ġ= ĊĠĠĠĠĠĠĠ ĠMutable State Flow ( Channels List State ( static Channels List )) ĊĠĠĠ Ġval Ġchannels Flow : ĠState Flow < Channels List State > Ġ= Ġ_ channels Flow ĊĊĠĠĠ Ġfun Ġon Channel Click ( channel : ĠChannel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ ui Events Flow . value Ġ= ĠMain Ui Events . Channel Clicked ( channel ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon Channel Focused ( channel : ĠChannel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġfocused Channel Ġ= Ġchannel ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon Ok Button Clicked () Ġ{ ĊĠĠĠĠĠĠĠ Ġfocused Channel ?. let Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ ui Events Flow . value Ġ= ĠMain Ui Events . Channel Clicked ( it ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }