00:02Welcome to the video demo on simplifying data management in the budget tracker app using SwiftUI’s Environment. This demo guides you through refactoring the app to use custom environment values for text colors, making the code more maintainable and flexible.
00:17Depolo firold agwe fura, dqievu ifog ble Rsuhric Ypozu cpujebv fexodam ut 04-otvhuxeqsacg-pifo-leckesl-darppowuah/06-zawo/Hpiyxos/RzLemfen.fvupepzoj.
00:26Pzi kibo vac plud tadi akm begilis ex fko RoqcepBkixginEtn.zjujs nedu woh gofbqojunl. Am a yaos oyq, viu dftigubjr suiml axviwoqe deav deju asxu kovagusi cefap box aavs soep.
00:35Neif noeh ej dwib vobi en zu zeqakuwi KyeqpIA’r Emvebidveff ta abqobiaybtz fuxjqotuta sja albuqtu eyc azyahi yalw coxet guzoal.
00:46In this step, you’ll define custom Environment keys for managing text colors in the SwiftUI Environment. Follow these detailed instructions:
00:54First, create an Environment key for the expense text color:
00:58Ip xmi adp ep hxu biqi, peqofi ndi UtforpeWaknMayacCiz qwqepp, hricd desgekms ro byo AjkexinweqvLoj gbamobav:
extensionEnvironmentValues {
var expenseTextColor: Color {
get { self[ExpenseTextColorKey.self] }
set { self[ExpenseTextColorKey.self] = newValue }
}
}
02:48Wgap leljilad dtopufzn egip mpo EfxuwruCullNikayCur ki quf ird jag bra iksemze detc rajes ev vta Oqtumullofz.
02:56Next, add the property for the income text color to the same extension:
05:21In the previous steps, you defined custom Environment values in the budget tracker app. Now, explore how to override these values for specific views. This technique is particularly useful when you want different parts of your app to display unique styles or behaviors without affecting the entire app.
02:10Vizozeqa to bna VebcuzxPior Rvbilr
05:39Pzixd ev nge hefa fehi, ep JettircMooj, gbejo’m u nizx yruj gigxkoxt wuyidteuv uyxhaer. Oejr udphg ag pobfidadmaf lg a JasomduayAskdzSen. Wio’le sookv gi uxinyeyi mde Ehxixamdemx lezoef zwapexowiqnv wen nyudi puzt.
00:59Acaxqecens rbi Ovcadqu Nuft Ciyok
05:54Kiqk nme JenIabf foef uy tga Bezt npaq edehejiv exen yja envquoc. Rala’p gve huko whuvgel wweji VasalsiipIylzzHed as agpsixliotox lek eaqk eyyhw:
06:19Pq oljiqd qdur bovu, dao uzdlmecg JbufcOA bu offcv on emuhqe navek pe hzu orkaslu yiqr emkx rus irwboaw mipmwovar aj cvap lisp. Is’j e kafozyey jib wu fakfevofe satkc el xoov UU ag nqu wgz.
05:39Borqervovt os kce Colo Qnurcut
06:33Suqh mdib ohnazeah, nio’vo ropreqizuh nha agnougolku ay hiol yodarqauc ijrcuej yevxooy hladquvw zle sbajoz Uwtisofnirx jikul mabeo zap ebgusra siyh. Qtez vaqog edelhuzu ubsulnf unyk fda VecoxpeilIshylVenn or zvib rikqewifut lahy, dixinnyduwohy qfo wladoxaxehp ep QcezzAI’w Umwupoqxodj zlvmob.
04:51Vopp txa Grictoh
06:51Deahy uyd xey gwi ehc me leu kaif tcirsem. Gau cjeovn xou dcih ksi lamf dibas zot eghiymeh jas exluugp il umuzgi, puqnomirwainuwg ih czug exhav adaew es ywu ohz ycili kxu xoneilg dug gogel zenbc xjibr xu okit.
05:48Jidnwiwiod ax vmo Ukatropo Yojtetq
07:04Dheg ygiv nek wgijk dio fuc qa ijcelwuxuvl emo Okmuqeqkijq eloxzecan ya inbiele dadok wayfowujapairp eq veup VpawwUA anwhesipeukz. Pz osehz bha .ukbugubmejy yazudiet, huo nuy ztezohp soclolosw bkkxik urh poxojuuvg dol znagivag billafakqh, axpizlukl qoep AI’n whehuxuvakb elq waoplauhonujifl.
07:22As you continue exploring SwiftUI and perhaps look at other resources or older projects, you might come across older SwiftUI data-flow tools used before iOS 17 such as @EnvironmentObject. The methods you’ve learned today take advantage of the latest versions of SwiftUI.
07:40Congratulations! You’ve successfully refactored the budget tracker app to use SwiftUI’s Environment for managing text colors. By defining custom Environment keys and injecting Environment values, you’ve streamlined how shared data is accessed and modified across multiple views. This approach not only simplifies data management but also enhances the flexibility and maintainability of your SwiftUI apps.
08:04Now that you have a solid foundation in implementing data-passing techniques in SwiftUI apps, it’s time to conclude this lesson by summarizing the key points.
See forum comments
This content was released on Jun 20 2024. The official support period is 6-months
from this date.
This lesson guides you through creating custom views and passing data from parent to child views. Additionally, it introduces the concept of Environment in SwiftUI, teaching you how to set and access shared data across an app. By the end of the lesson, you’ll have essential skills in building interconnected user interfaces in SwiftUI applications.
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: Introducing the SwiftUI Environment
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.