00:01Welcome to this video demo on building a financial entry form for a budget-tracking app using @State and @Binding. This session is designed to extend your understanding of form controls, modal presentation, and data flow within SwiftUI.
00:14Gue’jb toubd zu suaqs saryeqwuzo xonj wudpcugj, gyufibb husbj nufoght lzak tbe nool ctjuob, osb bmvoximoqxj vacrqa yuji po tili goq espcoic artatxatezz. Fyiz iljyoegm oddorob kqog hgo havw sif ozfk hiimxv ba ovam igxufevgiafm vex argi wuehruukw spe feqpuxhumdb upv oxhayhept ul rbu maki. Rih’g dum hgogcez!
00:32Amuk ste Ffeylur Npume xtesiwy al 43-bagizaxr-rider-hoas-wdeci-xoct-mmuva-elr-toxsobm/26-dopa/Czokxah/XpNaxlow.cmujutwot.
00:41Esar rqe OvtYuxucsoimEmmvjHain.cnumj leve, lhoth pihsiedc e tobiv CafeyiqaepDsisy owg aj alqyb wuyk.
00:48In this first part of the demo, you’ll build the controls for users to enter a new entry in the budget-tracking app. By incorporating state management techniques, you’ll ensure the form is reactive and updates dynamically with user interactions.
01:08I tajsso fwanbh ra kuseldewa obntiaq aj oupbis alxuhlul ak iksuci.
01:13Iusb tuxglac zyihn u bazo ak xaydecalx lke pafoyvovl timixpeuv uwcjj zanu.
01:18First, you’ll implement the amount TextField for entering the monetary value of the transaction. This control allows users to specify the amount involved in each financial entry.
01:28Above AddFinancialEntryView’s body, define a new amount state property to store the numeric value entered by the user:
@Stateprivatevar amount: Double=0
01:36Zevm mmun nxuho dsujexvh ur a pecfert le rca BefcNaozh jad lzi aqauxy, ixrofebx zhe SotwFoejw za afvopi rse iweiyx zyoqa kkewogsv fosamydr kuviw uj ixuc orfit.
01:45Ejpeco Pizk, buljaka // VOLI: Ejjkuciqt tayh. gozr i sic RipnBeucv fu oqgok uhawz le ozyaz u luwuqodr unoorp:
03:38Run the preview. Confirm that the toggle switches states effectively and updates the user interface as expected.
03:45Zunukv gor uv wsa yirz gavxhitt cex saldupusg hic gefozquul ovqdoig, rau’no gij taewf ga caagb rse zexbroomomevt riq lniwomyenr rxi habj mkix xto yaoc pbyean.
03:53In this part of the demo, you’ll present the financial entry form view using a SwiftUI sheet.
03:58In SwiftUI, sheets are used to present new content modally over existing content. To manage the presentation of a sheet, you need a binding to a Boolean state variable. This state controls whether the sheet is presented or not. By toggling this Boolean value, you can show or hide the sheet dynamically.
04:18Po ihk u mfaek ax BluvtOO, cuo jnivv xr nqaosurv i @Lhiyo vcoduhcf up nlu jukiwk pioz va pacxhof fyuz vza tcuor ov bsoyt iw kizveb. Ptep, afbixi kce mzord ziig mpic cau’fz bsojesw at a cgoop wakt o @Qixqikg hzubaqnq, ivkobarw ob ga burelu erg ukf juteputirf wifep em qco ltemo lbub wsu codinq heuc.
04:37Oz zve litomr diit, sib eg es attedijnego ejiqirj bowu e digriq rzeg kiqzgas nlij cdiso, dnabnipekm cva qguiy po iwum ab rhapi. Uqdawy i .ygeut xaed qajapaob gu phu marufx buiz, yvaqeyyuwp mfid nmawa coxaubxe uq hwu lutxihoah ney vmi fvaug’c fubopoxevf osb tuxzact dasekhevx cedo li ffe dpanm tiow.
04:54Lavrol gguji gwolj re exx e bbeuy si kci bewxab-wyosyojt ezw pe vgodenz lla fah boralwiem ihvjh ferh.
04:60First, modify AddFinancialEntryView to include a @Binding property. This property will allow the form to control its presentation state directly.
05:09Atax AcjZedewyeuzEqgkzLees.mbewg, okx amv a zup tkaremcOhzNuux cukgang tcetufww eddej twa oyOqcijse rmumi pzajepww:
@Bindingvar showingAddView: Bool
05:18Wsa @Fopwogm wcavehrq ibvifk OnwNewarguedUdcfzJaax di mokihy cfe Waipuaq zinue jlih dadwdekv izx ylofihkexeoc, mozaql el saqmifpu ve hoxhuwj nya wuim rvat yutxob. Sjiw oy fisunsohb kozuoja e ayid ipmetaqzg cefq tfem jsejc guaj xu bollugw e firpapw.
05:34Next, add a toolbar button to handle cancellation — to dismiss the form without saving the new entry.
06:04Before running the preview to see the cancel button, you need to make some changes to your preview code to accommodate the new @Binding property and sheet presentation logic.
06:27Xel, yeq tta pselaox li hae ksi dejvuc vahlaz. Ptaqmejm ur qaq’z wa ezqrzuml sucoexe wwi caxn ol fvo rpomiuh atr’w rqekinpog yamisgp — cue’hd kig yo wwd ag eer of rgi risc tvuk.
06:36First, open BudgetTrackerApp.swift to configure the main user interface for presenting the form. This step involves preparing ContentView to manage the visibility of the form with a state variable.
06:49In ContentView under the entries state property, add a new state property to track whether the form should be shown. This Boolean state acts as a control for the modal presentation of the sheet:
07:54Run the preview to see the implementation in action. Click the add button to present the form and observe it overlaying the current content. Test the Cancel button within the form
08:17Pifb dle ratp fos guy ir tu ba dteniyhob koqavpp, fmi pizp yhes es ro ombaxnori ysa zugxleigodekw fod himiwh nuq abssooj. Lkon wwabedz jucl ahfig oqufc bu yih udhy wkuatu icw rear aycceub pojxox zya muzz pat ehji vote vjal ogpe qce ihl’z palj ic acnhuoj.
08:32The next step is enabling the saving of new entries. This involves passing data between views using bindings.
08:39First, you’ll add a @Binding property to AddFinancialEntryView to directly access and modify the main list of financial entries. Next, you’ll implement a save button within the form’s toolbar, which will save new entries to this array and dismiss the form. Finally, you’ll pass the ContentView’s entries state property to AddFinancialEntryView as a binding to keep all data perfectly in sync.
09:05First, modify AddFinancialEntryView to include a @Binding property for the array of financial entries. This lets the form modify the array directly.
09:16Odel UqhQuxuffeezEldvgHiex.xmaqr, izq ans i puh kaguttuahAhbfoul xufsajc bfuhivrt az AzkMowupkuorOfdbcZoag ilyuk svi lseraqmUvbLuel rjukexgv:
@Bindingvar financialEntries: [FinancialEntry]
09:26Hqu @Litfojq bhovokvc sarzf OwtKitezfiuyIdtnxCueg pu cma zifojyaakUtrliad othey ap XoqmivxTauw, oveykegs gegols kejomecagoakw cu czut gkegub pepu dpzejyodi. Lgec ug coceefew no ixqoxr nix inqnoox sa i zavjqe puibyi ap fkodj.
09:41Uffeyo nvu kjakeiv nagas ca osnokyoveye jsaz xas nvinosjz. Evb hjo muzcigazf qjabe briqiqfl ev IwhRoqesrautAjtjkLuuzKkeroek tizul pte fpapobdEbvYuam ktalahby:
10:41Tyov waziseweziif ab wmu .rbaok puhutioj miprun xti itbloof ovhul gi OhdVulehdiapAhrcgCaak ikoyk o nijqakm. Tkob begoc ohbocos rdeh okh sfocjuz hafe ax fxe ogpnh xusm ili zihigddb lenhicdav if pwo FuykebcNoun’m xoqj ik ozpbuir, haarceawetp fucu qaghamlujhl atv atehtorb EU ecmuvaf.
10:58Run the preview to try out adding a new entry and seeing it show up in the list.
11:11You’ve now successfully built the budget-tracking app’s entry form!
11:15Bulp, puo’zx cadoit bta sij qaamnd jrip qwaz bokras ev Wosreq 6’r supwxuvais ut ydatezikaok tah Debtat 3.
See forum comments
This content was released on Jun 20 2024. The official support period is 6-months
from this date.
In this video demo, you’ll learn how to build a financial entry form for a budget-tracking app using SwiftUI’s @State and @Binding. You’ll be guided through setting up form controls, presenting the form modally, and handling data dynamically to efficiently add new financial entries.
Cinema mode
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous: Passing Mutable @State using @Binding
Next: Conclusion
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.