package Ġcom . ab model . u wheel s . ui . shared . signup Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . view . input method . Editor Info Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . annotation . String Res Ċ import Ġandroidx . fragment . app . view Models Ċ import Ġandroidx . navigation . fragment . find Nav Controller Ċ import Ġcom . ab model . u wheel s . R Ċ import Ġcom . ab model . u wheel s . databinding . Fragment SignUp Binding Ċ import Ġcom . ab model . u wheel s . ui . driver . apply . Be come Driver Fragment Ċ Ċ class ĠSign Up Fragment Ġ: ĠFragment () Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ const Ġval ĠTAG Ġ= Ġ" SignUp Fragment " Ċ ĉ } ĊĊ ĉ // ĠBinding Ġobjects Ġto Ġaccess Ġthe Ġview Ġelements Ċ ĉ private Ġvar Ġ_ binding : ĠFragment SignUp Binding ? Ġ= Ġnull Ċ ĉ private Ġval Ġbinding Ġget () Ġ= Ġ_ binding !! ĊĊ ĉ private Ġval Ġsign Up ViewModel : ĠSign Up ViewModel Ġby Ġview Models () ĊĊ ĉ override Ġfun ĠonCreate View ( Ċĉ ĉ in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, Ċĉ ĉ savedInstanceState : ĠBundle ? Ċ ĉ ): ĠView Ġ{ Ċĉ ĉ // ĠInf late Ġthe Ġlayout Ġand Ġbinding Ġfor Ġthis Ġfragment Ċĉ ĉ _ binding Ġ= ĠFragment SignUp Binding . inflate ( in flater , Ġcontainer , Ġfalse ) Ċĉ ĉ return Ġbinding . root Ċ ĉ } ĊĊ ĉ override Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . on View Created ( view , ĠsavedInstanceState ) ĊĊĉ ĉ binding . apply Ġ{ ĊĊĉĉ ĉ password Again . setOn Editor ActionListener Ġ{ Ġ_, Ġaction Id , Ġ_ Ġ-> Ċĉĉĉ ĉ if Ġ( action Id Ġ== ĠEditor Info . IME _ ACTION _ DONE ) Ġ{ Ċĉĉĉĉ ĉ on Clicked SignUp () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ false Ċĉĉ ĉ } ĊĊĉĉ ĉ sign Up . setOnClickListener Ġ{ Ċĉĉĉ ĉ sign Up ViewModel . sign Up ( Ċĉĉĉĉ ĉ name . text . toString (), Ċĉĉĉĉ ĉ lastName . text . toString (), Ċĉĉĉĉ ĉ phoneNumber . text . toString (), Ċĉĉĉĉ ĉ email . text . toString (), Ċĉĉĉĉ ĉ password . text . toString (), Ċĉĉĉĉ ĉ password Again . text . toString () Ċĉĉĉ ĉ ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ sign Up ViewModel . sign Up Result . observe ( view Lifecycle Owner ) Ġ{ Ġsign Up Result Ġ-> Ċĉĉ ĉ sign Up Result Ġ?: Ġreturn @ observe Ċĉĉ ĉ sign Up Result . error ?. let Ġ{ Ċĉĉĉ ĉ show SignUp Failed ( it ) Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( sign Up Result . success ) Ġ{ Ċĉĉĉ ĉ go ToBe come Driver Screen () Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun ĠonClick ed SignUp () Ġ{ Ċĉ ĉ sign Up ViewModel . sign Up ( Ċĉĉ ĉ binding . name . text . toString (), Ċĉĉ ĉ binding . lastName . text . toString (), Ċĉĉ ĉ binding . phoneNumber . text . toString (), Ċĉĉ ĉ binding . email . text . toString (), Ċĉĉ ĉ binding . password . text . toString (), Ċĉĉ ĉ binding . password Again . text . toString () Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow SignUp Failed (@ String Res Ġerror String : ĠInt ) Ġ{ Ċĉ ĉ Toast . makeText ( require Context (), Ġerror String , ĠToast . LENGTH _ SHORT ). show () Ċ ĉ } ĊĊ ĉ private Ġfun Ġgo ToBe come Driver Screen () Ġ{ Ċĉ ĉ find Nav Controller (). navigate ( Ċĉĉ ĉ R . id . action _ sign Up Fragment _ to _ be come Driver Fragment Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Destroy View () Ġ{ Ċĉ ĉ super . on Destroy View () Ċĉ ĉ _ binding Ġ= Ġnull Ċ ĉ } Ċ } Ċ