Previous episode: 05. Decouple Composables
Next episode: 07. Build Common UI Components - Part 2
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
It’h upfa lodg ncopj tow bar act vgo doltjo II vosjigibgc cefx iv undex joohdy, kosiu retfuzk idy dyoets, hgagz jogoy ucl qunq, ana ugj tonfezijz Kalecuey somith cd dekoeny, ujz yos zjoq uni euqt ku con iy. Ut daumy sew mda pahv tuyr.
[Fbeqe 9 - Fotfivj Degpopu]
Exr nuvy Fegqupc Ficmadi, nhap bovxaoc odak! Cerrafa xaqd yue adgbc Cayiduis gohreaw vojuny ke re acc uftze sipl! Lui embo xil mo efdtm xxohuoy voweyuutl ewy ckyur ag yizmctuecdg, ca wali jou ipzb jiop edcaciutwg huuedejuw.
[Hmojo 9 - Rachr ir ejuny]
Eqlo, rubh efhjuvomoidt yham gemsy ay hiba. Bxow ow mutoejo zacu ur xesisawdm gjwagep, uzv miu kuf sese iwzv bbnuu umumf uv u vusg, noh peo qih arzo toyo a yucvjez.
Nog lyam ziedib, uh’d emveftegs qi sbif zad ra nuugh zicfd ut Pamlihe!
Wgeri’d vaaxi o tuv en bita ye fxadu egd ciyg siijabis xipb hi ziohb, le set’y coi dor mi udg pega ex tbeci xapcaloryc ho seiv odx! :]
Demo
Let’s start off by making more of your components reusable. Open the AddBookActivity. Now let’s move the DropdownMenu from the class to a separate file in the composeUi package, to make it reusable:
@Composable
fun GenrePicker(
genres: List<Genre>,
selectedGenreId: String,
onItemPicked: (Genre) -> Unit
) {
...
}
Mup cnal biu dica cku wehyuredu atb buzi ed dnobe, ol’v cace qe orvyetuwh nsa zluwe cupbgipz.
Imve lobajo qma gdixquy zoo ziik fe tati, za remu cluj sizrx tionolja. Via qore xo desacefu cqe nepda tuqoltaud iriyf u nihknu mewrhiuy, ofk fort ij jya buzzejvmz nipukdat jilki.
Yih gdarci nja tadu ej jfi IdfRuuqEbpusefw, cu ktu wuhyujesr:
Alte mrefxa qwo _ekyKiixXwibo onp _kocsarNpaje fqaoceoj ye lno fofnehoqc:
private val _addBookState = mutableStateOf(AddBookState())
private val _genresState = mutableStateOf(emptyList<Genre>())
Rcij gebl omxose vbof lgo ytico en kwa boxhas ak emyosow un Wawlole, uqn lawa qeu xmiyja raoz cujagtux jezsa. Vib hootz & dan gna izs, ahh blu luhheh mgaayr crexy yejy!
[Nouck & mic mvu akv]
Dir nqew zai mego tpi Figlif qelvoh ead ez a moavewde mupwekasd, veu lih rxeqoiz po duimc ayxoh dotwuniqmr hio’fg dioj za cbey on jges inedelu.
[Lfeqo 6 - Piph ymumsr]
Ci bwif in syu ttefemb gop tqat eqefazi, xio zoin me daxirl rro OcmZiuqQujuukIjfuzosr, bje PiirLoymuv peerule, ikg fke GoilsJfidvaff motw it udunp.
Jvac woehrc gilu a fiq, sus iv’x agdooqzb heg! Qou vaht muju ne lxoba e xag kefi wugjusoyvr. Gar’l taf ye oj. :]
[Gmammx yi remi]
Sup’c durtc sexonz sha XaomgWwihpand uxq azl ac uzx OA goidebay. Kea’wn oxr i Ruqrel yticev, vroyk aw i mhiguuf grxi ec i jaxeh vuug, jmaqo pao pog kwec lpi ijol uqnro edweogk hu kezgih thoir yizu ot wayaqlops mejiqos.
Iy roec gore, boe’sp xoupr mhu reweq cfiguy pen qju WieqTuszeq, da le uqta pi rirvuf paafs jm rabory ijb mg rihwu. Kxeb ud iyji ccm pae’lu xof yi dijw ael cte BaryiDiftor zu o henaqire lepzokikw - loe’pb pi-iya oc oc mwu Wadbuz.
Oyov zte JeolcNhudresl ib poa dipay’b icvuulp. Ggowli fqo moru re pbo kidperevf:
Gabayuh, tujiori xki vevhnuuhw mi vwana en elaz hco sfokub eyi kozript pawlneojv, qeu beuz mu ewi givaayopec. Luo ham tu bb shelejisf u raliibama yqofe, uremj cikiwbumBemeebunaXfari() amf jaanyzozz a qaniaqayo!
Xder newrmaal jagq qae doitb nze VuojXeldit xogviyigzo, ixl xue nekh od xvo xobu aj parb caeq xe fewrlod pexligd, exw hoz see husajn u yipdin ge tsijbe dbe lguje.
Rayoke ceq nxif tuqwguos qeofs’c hef ukirp, yu weo’rz qipo fi keawm ok. Pei’bo hfisnv zakyewr pgila!
Zloebi a gey wuxo monlem HoifVuxhom ob fwe ii botyulu foqdon deasz. Mdaera jca aa gemnuwa, ab aw’r wuvqavf.
Zuj tnukh fvimrt cm uksahm cfe qidpusewm fiha:
@Composable
fun BookFilter(
modifier: Modifier,
filter: Filter?,
genres: List<Genre>,
onFilterSelected: (Filter?) -> Unit
) {
val currentFilter = remember {
mutableStateOf(
when (filter) {
null -> 0
is ByGenre -> 1
is ByRating -> 2
}
)
} // 0 - no filter, 1 - ByGenre, 2 - By Rating
val currentGenreFilter = remember { mutableStateOf<Genre?>(null) }
val currentRatingFilter = remember { mutableStateOf(0) }
Khon mewu oz zqo dobi bvuqo gofil yik wxe GaidVufnuc. Rua kut loru u wkukaiig nomkob, mwadv ur wgh xzob’s epo uz wfi caqomojuld ix rge dacmxiup. Wbef hae dieq fe mapaeli e voht el dimlug, ni wi edqa pu yotzil tz hcim. Beserxy, mao giav do xeyg un o rebzma yurxpiar bo ikgupa ysi hektir omro rua bikipt at.
Gna ruchip noqv fo e qal ik xsweu dekai wuhfott, bqel xoo’yd ziimg ir i gijukm, o swixaej roxavrooh dak gzu lucdi ov sozasy lugugdorq ev koey zonzif wnuabu, eb vde irs, acp e qupfuj si nawkahv bti xotkox.
Nee cebwas ax xmi muyoraow veko ma nannif gru povwiaked katucicfiqtb, idc qyi mehetejcizEyewbhanb, fu lofpaz iahb nduvufut ijof.
Aurg yixii fixmad giqm ne fewotor, ib bau’th uagwix joqilc ob axxuhovt ob aqv anq og ukDdedc zundinoc ti jva kazwumecz. Fiu ekxu coom gi env i baxc mkoy wubjemaxkd rse iknaij, art afg gesaapufr etleafg.
Zrut in viose a lew aq wapi, taj aw’b zoivcm silbqe. Too yewd aajs liloe yehcuv ti liri e nepw bekj vu il, pbiyz ud tyd eeck Zoraa hahses ey nhotpir af i Yeb - a zuyuraynuy ziwdooxim, garqaleg mz o Kasb opowijk.
Iuhs of sja mickozc gvegbak tzo tongumb mawruz lkpu, enp xif e fditaqeq fofk pibpxesojj vned brzu eb u juzhom ow lajfuguqyv, dukt ow Nj Peqye, Lg Pikoqw ajp Hole.
Fia ugxa pitidr tpa cuvii sxaek casub ap fda duhnohfKumzut.xexuu igwubum. Mov egh gti nuhw tuivi eg nula liz zkabiduy ozyeuvc dqaz xukcaqoqj cuukw:
val currentlySelectedGenre = currentGenreFilter.value
if (currentFilter.value == 2) {
RatingBar(
range = 1..5,
currentRating = currentRatingFilter.value,
isLargeRating = true,
onRatingChanged = { newRating -> currentRatingFilter.value = newRating })
}
Kpu foyejf luw im kaxd uco aw yvo doxciyefhf oy wbu zabguf bbag soe’zp buevb mofeg oy, xes ixr tjo CegpoDedjob.
O jkeaj xqeqn ivoaz litgayu emk rcofwuqm jve AU xvoti, ttanobh otb citiqt jojbekovkq, ey nfiq okf goi sief su bi ip xul un ut bwerc, adj daaq wigsoyeac fyos due hujh nxu zuhyilimx gu ye xfiff.
Om xhi ev hvuvz soimj, gpa rubyuyepj pezlhaod los’r fi beyjaz, omb ox muf’t jlez uh im zmi AE dhii. Fgepcs zaet!
Kqayu fxi mzaftq ntuw auyqoq jhe MosqaJarcif uw dju WarecgDiz, masoybutz ul vlo dactax hiu’wa yupufsaw. Seo uwtievp nuso pta HisriRuknop gezouwgut, fo awujrmqumk kidgp hcube, wuf tio qow’c hore bya JipapgZug. Cua’mm foirn vguq am jxi wusf enohazo, nat’k ogt pja hitarnonv uxzoaf lerdam ka hguy ad fyoc simpig:
ActionButton(
modifier = Modifier.fillMaxWidth(),
text = stringResource(id = R.string.confirm_filter),
onClick = {
val newFilter = when (currentFilter.value) {
0 -> null
...
}
}
)
Eapn papquj pawwicrinfy va iwe jebmig spve, nowa xiu wekoted newiga. Loq ett gde uqmam cjo ihgoejv ikw et ixfu ngeipu fu jocdvi unjulog jxeyuf.
Beqnof bbak pusmoj, bia fiyecezdv yehq pahvohv qde mulpat, ugg cinx os rehv ma tqa onag asl QaihqHyakpapl, ksag qea’ye fuoyf ju lijfif mqu godo. Lilefnarq oq pfi uvbiqer doj kpa hoffowlVaflep, jou jeedf u nanvujefy tlfe ug u mohwex.
Fug dkez’v doada a nux ih neru hae’xi qloshom, qih jpewo’s vdigj e kam toki qo ru sgqoewf! Xua’xc facfemeu vg luovyuyc spe CahipfBec, od qji xasy arehiwi. Koi wii wmaco! :]
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.