package Ġcom . v ish al ga ur . shopping app . ui . home Ċ Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . fragment . app . activity ViewModels Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġcom . google . android . material . dialog . Material AlertDialog Builder Ċ import Ġcom . v ish al ga ur . shopping app . R Ċ import Ġcom . v ish al ga ur . shopping app . databinding . Fragment Account Binding Ċ import Ġcom . v ish al ga ur . shopping app . ui . login Signup . Login Signup Activity Ċ import Ġcom . v ish al ga ur . shopping app . view Models . Home ViewModel Ċ Ċ private Ġconst Ġval ĠTAG Ġ= Ġ" Account Fragment " Ċ Ċ class ĠAccount Fragment Ġ: ĠFragment () Ġ{ ĊĊ ĉ private Ġlateinit Ġvar Ġbinding : ĠFragment Account Binding Ċ ĉ private Ġval ĠviewModel : ĠHome ViewModel Ġby Ġactivity ViewModels () ĊĊ ĉ override Ġfun ĠonCreate View ( Ċĉ ĉ in flater : ĠLayoutInflater , Ċĉ ĉ container : ĠViewGroup ?, Ċĉ ĉ savedInstanceState : ĠBundle ? Ċ ĉ ): ĠView ? Ġ{ Ċĉ ĉ binding Ġ= ĠFragment Account Binding . inflate ( layout Inflater ) ĊĊĉ ĉ set Views () Ċĉ ĉ return Ġbinding . root Ċ ĉ } ĊĊ ĉ private Ġfun Ġset Views () Ġ{ Ċĉ ĉ binding . account Top AppBar . top AppBar . title Ġ= ĠgetString ( R . string . account _ fragment _ title ) Ċĉ ĉ binding . account Profile Tv . setOnClickListener Ġ{ Ċĉĉ ĉ Log . d ( TAG , Ġ" Profile ĠSelected ") Ċĉĉ ĉ find Nav Controller (). navigate ( R . id . action _ account Fragment _ to _ profile Fragment ) Ċĉ ĉ } Ċĉ ĉ binding . account Orders Tv . setOnClickListener Ġ{ Ċĉĉ ĉ Log . d ( TAG , Ġ" Orders ĠSelected ") Ċĉĉ ĉ find Nav Controller (). navigate ( R . id . action _ account Fragment _ to _ orders Fragment ) Ċĉ ĉ } Ċĉ ĉ binding . account Address Tv . setOnClickListener Ġ{ Ċĉĉ ĉ Log . d ( TAG , Ġ" Address ĠSelected ") Ċĉĉ ĉ find Nav Controller (). navigate ( R . id . action _ account Fragment _ to _ address Fragment ) Ċĉ ĉ } Ċĉ ĉ binding . account Sign Out Tv . setOnClickListener Ġ{ Ċĉĉ ĉ Log . d ( TAG , Ġ" Sign ĠOut ĠSelected ") Ċĉĉ ĉ show Sign Out Dialog () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Sign Out Dialog () Ġ{ Ċĉ ĉ context ?. let Ġ{ Ċĉĉ ĉ Material AlertDialog Builder ( it ) Ċĉĉĉ ĉ . setTitle ( getString ( R . string . sign _ out _ dialog _ title _ text )) Ċĉĉĉ ĉ . setMessage ( getString ( R . string . sign _ out _ dialog _ message _ text )) Ċĉĉĉ ĉ . set Negative Button ( getString ( R . string . pro _ cat _ dialog _ cancel _ btn )) Ġ{ Ġdialog , Ġ_ Ġ-> Ċĉĉĉĉ ĉ dialog . cancel () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ . set Positive Button ( getString ( R . string . dialog _ sign _ out _ btn _ text )) Ġ{ Ġdialog , Ġ_ Ġ-> Ċĉĉĉĉ ĉ viewModel . sign Out () Ċĉĉĉĉ ĉ navigate To SignUp Activity () Ċĉĉĉĉ ĉ dialog . cancel () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ . show () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġnavigate To SignUp Activity () Ġ{ Ċĉ ĉ val Ġhome Intent Ġ= ĠIntent ( context , ĠLogin Signup Activity :: class . java ) Ċĉ ĉ home Intent . add Flags ( Intent . FLAG _ ACTIVITY _ CLEAR _ TOP ) Ċĉĉ ĉ . add Flags ( Intent . FLAG _ ACTIVITY _ CLEAR _ TASK ) Ċĉĉ ĉ . add Flags ( Intent . FLAG _ ACTIVITY _ NEW _ TASK ) Ċĉ ĉ context ?. startActivity ( home Intent ) Ċĉ ĉ require Activity (). finish () Ċ ĉ } Ċ }