package Ġcom . te amp ym . online clo thing shop application . presentation . client . toc Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . te amp ym . online clo thing shop application . data . models . Terms And Condition Ċ import Ġcom . te amp ym . online clo thing shop application . data . repository . Terms And Condition Repository Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . channels . Channel Ċ import Ġkotlinx . coroutines . flow . receive As Flow Ċ import Ġkotlinx . coroutines . launch Ċ import Ġjavax . inject . Inject Ċ Ċ @ H ilt ViewModel Ċ class ĠEdit Terms And Condition ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġterms And Condition Repository : ĠTerms And Condition Repository Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ edit Terms Channel Ġ= ĠChannel < Edit Terms Event >() ĊĠĠĠ Ġval Ġedit Terms Event Ġ= Ġ_ edit Terms Channel . receive As Flow () ĊĊĠĠĠ Ġfun ĠonSubmit Clicked ( terms And Condition : ĠTerms And Condition ) Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġres Ġ= Ġterms And Condition Repository . update ( terms And Condition ) ĊĠĠĠĠĠĠĠ Ġif Ġ( res ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ edit Terms Channel . send ( Edit Terms Event . Navigate Back With Message (" Terms Ġand ĠConditions Ġupdated Ġsuccessfully ! ")) ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ edit Terms Channel . send ( Edit Terms Event . Show ErrorMessage (" Updating Ġterms Ġand Ġconditions Ġfailed . ĠPlease Ġtry Ġagain .")) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsealed Ġclass ĠEdit Terms Event Ġ{ ĊĠĠĠĠĠĠĠ Ġdata Ġclass ĠNavigate Back With Message ( val Ġmsg : ĠString ) Ġ: ĠEdit Terms Event () ĊĠĠĠĠĠĠĠ Ġdata Ġclass ĠShow ErrorMessage ( val Ġmsg : ĠString ) Ġ: ĠEdit Terms Event () ĊĠĠĠ Ġ} Ċ } Ċ