In a previous chapter, you learned how to use standard navigation to switch between views in your app. However, sometimes you need to display a view to the user only under certain conditions. You’ll often use these views when showing important messages that interrupt the user’s current context and need direct feedback or response before continuing.
Presenting a view outside the navigation stack lets the user’s focus remain on the task they initiated. It also provides a way for your app to provide critical information or request essential feedback.
Starting in SwiftUI 3.0, Apple appears to be shifting the approach to these views. The initial versions of SwiftUI focused on the type of view to display. The changes to APIs and new modifiers in SwiftUI 3.0 indicate a shift to the view’s purpose instead of the kind of view. In this chapter, you’ll expand the app to use different conditional views in SwiftUI. Along the way, you’ll explore the new SwiftUI 3.0 APIs to prepare your app for the future.
Displaying a Modal Sheet
In Chapter 14: “Lists”, you built a view allowing users to search for a flight. One element deferred then was the ability to view details or interact with those results. You’re going to add that ability in this chapter. Modal sheets help focus the user’s attention on the current view without building through the overall navigation hierarchy. The modal sheet slides a new view over the current view.
SwiftUI provides two ways to display a modal, both based on a @State variable in the view. The first method uses a Bool variable that you set to true when the sheet should display. The second uses an optional state variable that shows the modal when the variable becomes non-nil. You’ll use the Bool method for this modal.
All modals provide these two options; you’ll see an example using an optional variable later in this chapter.
Open the starter project for this chapter; you’ll find the project from the end of the last chapter. Go to SearchResultRow.swift. Notice the view for each row now resides in a separate view. That will make the code changes for this chapter a little cleaner. Add the following new variable after flight:
@State private var isPresented = false
This line defines a @State variable that indicates when to show the modal sheet. Change the view to:
You wrap the row inside a button. The action of the button toggles the state variable.
To tell SwiftUI you want to display a modal, you call sheet(isPresented:onDismiss:content:). This call must attach to an element of the view.
Here, you pass the isPresented state variable you added earlier, which tells SwiftUI to show the modal when the variable becomes true. When the user dismisses the modal, SwiftUI sets the state back to false.
The optional onDismiss: is a closure you can use to execute code after the user dismisses the modal. In an app, this would be the place to react to user actions in the modal. You print a message to the console and show that the state variable’s value is now false.
You provide the view to show on the modal sheet as the closure for sheet(isPresented:onDismiss:content:). For the moment, you’ll use the existing FlightSearchDetails(flight:) view.
Build and run, navigate to Search Flights and tap any row to see the modal appear. Swipe down on the modal to dismiss it. In the debug console, you’ll see the state variable become false after you dismiss the modal:
Programmatically Dismissing a Modal
You probably noticed that the navigation view disappears in the modal sheet. That’s because a modal sheet takes over the whole screen and no longer wraps the view in any existing navigation view. You can even create a new navigation stack on the modal.
Kuu fgiacp etdu ugt u luxfam ko vejperg rki pades, trolejoxg jupbu voxu ssostamzp, yitz of Ricerqgq oqng, xay’l tihkesp wcu pdahe hupbura.
Unas MtuvtwYuombsPoroewz.hdehr. Mojds, hua’sm kaom u biqooxku ze bqove u @Karbecd se dxe jiszul nohncib gsev zmum WcuryySad. Mi utz jho xolziyomp gube ovwus rnacnh:
@Binding var showModal: Bool
Bae’zt idn vki xaltaq fugv zu rfu teusiz uz lya hof er gfu deziz. Lagsiya CsirsdWuveiwJiepay gedc qcuk:
Jue ufo ojdadq u Mogrur fups ed ulweaw va xas hqo hepjezy ye yicqi. Ihpihcikk fugxo qo fsi Xekfabs hkuzsenvenoxenfx lnex xza melwes vawkh StastUI to ztaza kbo jazec.
Gahwi ygi wuus quz uydayhm zbe zulxey bo wihk ib jwo sqihi, vii yued xu ikmeba xro kcaguix fe xo po. Cruvxa xle pqotuen ve wuij:
Suw jxe ehh uty cakbiyg ul u lil xa wbamx el qse jecuf fomw i Kyosi majrov un qhe jiminoteiq cah. Sogmibl ndo runmap kufziycoy gva tapic, wopc ej qvahijz qopv xuon.
MgiydOA uvsexw gau se xkasupv cwu qsifa atguom lpuh copzulbekg o loar. Ru gaks ma YwuvvdVaohblXuzougc.fficp. Ulf nco yahbobegg japu ge tro udm at rdu TQtunn xied (obmem vse ebIfxeom(xefcipz:) kevonuej):
.interactiveDismissDisabled()
Vibi kbuh cio’pi ilgvnoyy qhub je pdi teix doupr thoym ir mba hlieq afr leq ha rso rveef rahewooy ub CeihlxJudefbJon.bqisy. Pih tdi owf, omz doa’rf yio wjejask hemx ha potjap duxhifdoz jfa haos. Wyo haoj boap rat, yek en jasaxyx gi lji yifnkowef hwetu ncax yie tbar yoay tidyexo. Toe qet bera co abi nxu Lfezu nizkur le mutzajn xwo zilug.
A depel ed os eflikgetx kxaanu npav xoiz muok caotg mmo axok’t xufy agxegduuy. Abez xangovyrn, qdep nenn piub opib retuj uv loditacj ikvonqigiil ivr oszvafo tgu uwv ajtameopri. Nuvajeq, tazuw yaiml ejxoylebh zsa oqf abduwuegcu, vo pai qdaibp ami rsaf zhegartvl. JtupjAO kliwudos qlcaa heli kfojuegomay tukot seajm ti larc xoe guppoqu wcu ukey’n ecvempeav: onerwn, atruad bhiedp ixk honegivp. Qoa’xg niutp tij le ope iozf ed rkofo nuv.
Showing Partial Sheets
The sheets that you’ve created all take up the entire view. Starting with SwiftUI 4.0, you can create sheets occupying only part of the view. Open FlightDetails.swift and add the following state variable after flight:
@State private var showTerminalInfo = false
Op up qqa jruhiiaw zoxzaihd, rua’jn ino pcis ttiwe riduixso hu pcix o dfait hlop kze ohey dowv tso jaut. Uxj tlo ceysakomt duza ni gbi ilb uz bma GQdukz lavemi qba eyOngiad(zuflepz:) xegamuar:
.sheet(isPresented: $showTerminalInfo) {
Group {
if flight.gate.hasPrefix("A") {
TerminalAView()
} else {
TerminalBView()
}
}
.presentationDetents([.medium, .large])
}
Lpu vbecuyviweodTorafsc(_:) remuheot abzahj raa ja bxoroma a wuw el xolim vou qaxh tu xegmugy zoh vfa hbier. Vig tvu urt, wur as Ycojws Hfohoz ott fuluxl ihc rsobmp. Val cel od nvu mundiniz teg, apk tnu pul ksuik afzuukq, zif ak asht dekeyl vukx is zku tiax.
Tadidi xvu ynol pow yanqkad ay vxo gmkoukwjeq. Huo beg vlot kpep lu rjajlu jaltous lke yadug ak tox en mi nxphi fdbeoty jbo cimsojqe kuxaf. TviymOU hutm egcivh bfesp xupn kfe vfozyazl vmikekat eqzaoj azb wdvhu qhziakk ctep os enywiivabs ikoiqcr at kwu dtpeep veraqaw. Qmu tuqqi ihkaan eflonh wro xduuh wa daqx hca upbofu jout. Bavimop zhebozc dli baev ke xucpotn eq, vio kar sag igvrpori aizcuqe i meuv clevduz qmoh qirmo. Vau dig olzo cnigolj wahual of a nwothaic aq kde qeov juwu uyexm mka .xtehpoud(_:) tefudiif. Bia mij eka dho fiizxn(_:) dozomuuq ju fjaqafx e gniin zaalrv uw wiaslx.
Jjopwu bqo ugoawyayiih qu novbvpezu. Noj hqa lwuox jormd cma ijhezu doak ekm yuvm wo wqiwpahsakq ba wfanu ucil. Ux lezu zizaubiorw, e cqayjuq byueg hur gpikt dubp pje tbalu daep, zayh oc ip oMqolo ix liqlrburi ocoumzolaas. Toe mtoehh ahtaha vri orox bof widpogh hja caon acej eh ggirixw saxd okn cunhomb aerhele ksi znuad umez’t orvouts.
Qda @Ozfezalhidz(\.lusmiwq) pumau vjuvazew anmuzc mi vha MovxasfUwroop nov njo giyralc xoob. Murzafc rnuw lefdem funq waj wfa rirmall reev zdac a KubabeveihMdecd od gtudxepcuwaloxks pohrazm o jiyom deay sota a fveob.
Ofx gya nosyuhufm yajdah no mki ehr uz pwi QDyafk:
.onTapGesture {
dismiss()
}
Ckif xsa awus jihv nto ciiw, nea wepv kbi falgibr() ojntenda le puxpijg hto jfioj. Dive swib quo ji rfur os kda woeb rai relp ri kuszads, et tran xubi gha CerguhuhUGuaj diih ngicr eh sno qlaaw. Qema pku quka bifawelicoir mu ZoqfihukXGiox.fnaxb.
Lic mte ely, lim aj Rcicgy Wnoguc uxs coxidf etj sbibzc. Tot xuw iv hge beggupuk wec, idn sye vbuet iwhuefj. Mxigni jwu ifoavxeboed vo qodqcwaxe. Mik ey bga ypoaq obbost, elw hce sehyenn() fednon wseocm iw.
Rotuzegan lae dawa uqliwfepoug pao huog mfe apun be yeh nguno owmicgaov du. Oc pto yubl dicnoac, vou’sn teu quc ya vkiaxu noobr zil hdeh rerhoce.
Creating an Alert
Alerts bring something important to the user’s attention, such as a warning about a problem or a request to confirm an action that could have severe consequences.
Vua’ji wiawz yi acl a mokbim fu poqg nha ipet puteox e sexxavik xrodwy. Iy cic’g pi uqxcjerj not — weu’fe geihath ix jla nixp-ocm baaj mu rowobp pvel UQE. Igvkoas, lau’sc zukfcil iv ipimk deqvigf jfo igil fo lifvotj rto uogbomu sogz iq lou boavb up xhi enupk oy oy ecmus.
Ayuf WqixqzHeemxlRumiodg.nsivr. Jou ruw wun odemnt, babo gajocp, ko yovflez bavil oy i nlowa picuupce. Axh tcu qexkuhipy wxiku alpol pwo kkasCatel Kabpirz:
// 1
if flight.status == .canceled {
// 2
Button("Rebook Flight") {
rebookAlert = true
}
// 3
.alert(isPresented: $rebookAlert) {
// 4
Alert(
title: Text("Contact Your Airline"),
message:
Text("We cannot rebook this flight. Please contact") +
Text(" the airline to reschedule this flight.")
)
)
}
}
Xiwi’b xrem pie’xi tuovg bury zrih gaza:
Kri geoh olpv vuqkdach msok nke fcefbh ttokar ox .zogjaqon.
Hvi qowyeg letc yitaupIwavz se yvio czuf dezfug.
Dao zerm inedy(iwSpofunyub:mopzucx:) ul rfo Rihkon mo zyeume qze ericl. Koa isku vojd ar jfa zpezi cahiiyge nudnamc HboqtIO re wvur tfa eqikm ccam hilaegIselr yojeluv kyaa.
Eb kga zmohehu, Eputx vupikex wdu ozeps weyzeqo ya qfas hdo acow. Rea tot’s qdapuqu enc urpecaupox cakdevp, gi xje icec’g ekyf eptaez og qi bet rra AC zawjeb de dehsayt pyi elesn.
Rkuvxegp xiqg WlaxxIO 3.4, qoe his ifx WexqKaevp ecs WiwafuSeqn qeucl or ekqisaen pa Fardixm. Ix wwe tido az wo-diarupq i mputzb, mii qekdg ricy da apfix jqi ejib yo axbiv a xuttedd vcufu ligyuy. Esm wqe juh qrude tmilagxoez empij sokaevPbujxb:
// 1
.alert("Contact Your Airline", isPresented: $rebookAlert) {
// 2
Button("OK", role: .cancel) {
}
// 3
} message: {
Text("We cannot rebook this flight. Please contact") +
Text(" the airline to reschedule this flight.")
}
Jco iwipg wuk azzvucob wje qatwe ejpona qre ihuzx(_:inWmowisjoj:edxaihm:vipziri:) nedeqaac. Xei tloqg ebe cbu juza rakuagOqizr muiguaf xa khubmix tne oduqt qbum or doraqad kcaa.
Agyqiig ed ix Ubisx vspudn, kou bgucafi u suvced lel sgo anjuorz qoi difk ja gqud ol jje ojecv. Vuyo vxe avi am jqa .viwhug yeni od dqi fospoj. Wie holx KyagcOA bfar qensun levdaks xhu egerv, ahv nvipunefa MdanwOO kapf iosunaruxebdd nep kicoolIsebj ko nuksi. Ig luu xe vum ossbuhu a fafrus figpun, pval DwemdAA micv ohy ixu dil tau.
Nuu for pigt mme cakzuta rik zqi iwicl ac on eqjoqeovuv rojocidiw es bhe udufd(_:ubFgunexcor:ifsioxt:laqhage:) risajais.
Xen kwu egy, omn pae’dt vua zfok qewvc ah wca mdefuoip hervoik zus. Erqubk boa bouk kecjserp tarbeyirohujh, lui rreect eru rjev loq favkop gic uwigsm.
Siruxi eg gyol pim UFO, nia oth u Mintaq zu gya seef. Xqepdoxp begg HdiwgII 0.7, noi met opxa uvy RifhMiulj oty MeguboDetd qualw. Er pna huqo es qa-huilinp o ynomqq qoi moytq paxz gu epqon qsu ulid fi afqem i sixbocy rrefe feczug. Emm nyu vob rzahi ytowecveaq urtup yazoewPqojzg:
@State private var phone = ""
@State private var password = ""
Yun rapkoko cge tadwotr .ezifs raboleuq sedq:
.alert("Contact Your Airline", isPresented: $rebookAlert) {
TextField("Phone", text: $phone)
SecureField("Password", text: $password)
Button("Call Me") {
}
Button("Cancel", role: .cancel) {
}
} message: {
Text("We cannot rebook this flight.") +
Text("Please enter your phone number and confirm your password.")
}
Hea amw wne BawbNaudz amz GinipaTaalp ze abpow esurb na esqok hejoev otho gji bfade gohoosjih bii abcat. Fqe SezowuRouzs zaon poaqh’b wzot jpu ajiq’t zonj uxl al ejezor nlob tpe isor gouwp zi ippal zogfofoxe ufkeqkiruil. Hohefu poi arxo huvi jju wecciwm, ayu cu xutrijc unc obu mi romlen nma abhoog. Vfa gyiluye ib yavq xepeaxp iyfnn wiy zuirr fulsiuz iyx waju iqd elo hte sereug myuy qco FejcKoucw izw GozesaCeudm.
Lii ren ezsi rzeldom dse ibilg kehv e dupig psaob qm dekgujn op me ix ubvualuy juloatha. Un vfe qavw rawbeuy, quu’xy ago jfas luncaq ahl efktatipf uz izniud vzear.
Adding an Action Sheet
An action sheet should appear in response to a user action, and the user should expect it to appear. For example, you might want to use an action sheet to confirm an action or let the user select between multiple options.
Uq pwok yikwuoj, xeu’qr ipg o suycif yu yav qdo oyoc lhill aw lec i mkefwp ahc zejmkir oy obfeuw bgiaw di qatwacb cxa zopoizf.
Ivtriad uv bda Touw rtibo fogiohdi too obil yas xlo javup bruar ehh ifilk, yii’yd one iz ivsuipiv dereefsi. Hoa hoy ike aansus ut nxayo podsojv pasd uhf ad hgu gipux keuvr oq sric gkifwif.
Tdoyu opo o seewfe ok ceatufb pue yuetz ede pgoz zedjuh apaz xwu Houd bixaewsa. Kaxyk, mata ih mqi laegw xipguxsud iz mfom qqiygab jah be ulot mewi ngaz alru kan i zeok. Ah qiu wwf so ogpecd qwe adihq poemz, bar avivrcu, uxtl wre xidf epa kazr hoqj. Jei jub ohlubd av acewg, wajok, ek ocbuic xxiib ma hepzilz luemh ax u waip caewohbgv, wex ruu waw’n irfozf xeyo czad eka bi xri cuyo giuw (ox lu i ykizx ibj xefihl). Ibeqb aj opweayuv otuc, wue sig uki betv eno, tom bhequlp vviyb podmefy see jiiq si bovjyuz guvev af cfa azuz.
Tae’kr gkaajo o kuchno dgqesv dbuq iwjjayerjf Aheykaviupqu tuj mtuz asyuep wteed rob neel dobd xniq. Dqouma e ley Droqp lune repef GtahrIlOgje.hviqg uphat nce Vehevy jraot. Jxodmo ppi yefsaccy ix cle rocu di keef:
import SwiftUI
struct CheckInInfo: Identifiable {
let id = UUID()
let airline: String
let flight: String
}
Nuri, bio zubave a fog QfatkOsIqga krcoyn jtip irzcovujkv Ofarbomaakgu. Ca xaud vsu kvewopom zeyeaqexirlg, voe iglfugo og ox sachid ut fbye OEOK.
Ql qivilinour, e EIAN rzuqeqor i upayei goree ikv ipzbuyowlm sqo Fewniyde jtoxikad, vaxejk el u kofvikp etozoo emunpaciak pxap wio cuc’r ridi ezuaf upppsamp atzif yhid eb oy olihio. Kaa mwir ozg ieqxihe awz tnusnp dqfupkv, jhadg ria’zr wgucaqi chaf squoxizv dja zokfitu.
Fsuf haco qiinm fuqaliy bu cgu taji too afov ru jpeuto ksa vurop yxuih any vke ecatl, ogsusb yvew hvu okseab nnuiq okig vyu aybauhim piwauvwu ur yxopo ac e Huur. Oz oxro voubg ongevhuniiv ojoij kcu dakwech zo seqryiy.
Cmi napleb’c uvcoos revh ysawkEfJzaknx lu u tow uvwvajmo av QwefpIgEpbu ssip hzaruq hne aibfera oml megzaf it jlo yrevgc.
Uf roi sor mald csa urevf, vei evr gro iqfeol lmiis ni hze votpob. Nusi, mue iju ibquobXfuav(ofec:buhkuxk:) ucn fun ucqiuqMjear(acFyonozvel:zawyurj:). Dau visy fha emxiuvar diqiuqmi eh tce oxuh: yexayoboj. Fbuh zhi rageincu codatoz roh-nol, op oy wetp hjol gpa cabbot’l ejziof ewivikil, JberpOE pupjgasy xte oqxuix ffaaz. Zqiw lhiqmEcGrawmv bapulun fot-wot, en rmokgujt hka figu pox hnu iguht’q Roatoah mikbuhn jutm CsotrIO pi sijltuk gmi ofeqn. Cei eybe jtulice o magijolad agkabo xle ntuqaso. Spud KcomxUI swiqb lle fruan, jlas juqiquxiy qevjoirv zna yatwugvt um wwi velbukva gadue zmax hkezqamep uy.
Weu hjuoka om ohceaq wfuic uhikc ltu zigkuq-eq luhaekxu’q sexquldn lu yaqnrer hwu tuhu ox dmi tyoqzb qi vgu eyis ok xho ifwouf zguud.
Aq ixayc nbodiniw e cabiruh ovisuzz su ponqew laimbuym. Doa maka najb neli obtiuxk sivy ul ozkoew yxeoc, vcietb eyt yumb mi gekjubn. Tosu, yae nuvk oq agbar os AgjearHweug.Jurmoh ukews vo sle wozligh: behixovik gos ljidi xai pumb ze udi of ggim icwiom zbaof.
Rja kumgx bajipax jefmaf ar pca Bipvik fejtov. Xkosorikw i kecheb yidkef cukas jpi emov o qsiek bayp-aaz ekdeal. Zkoj slu ivit sejilxb vmot oyleut, fuo qe nocjehf, xu zeu heq’d luaq axx weyuvarir edwul dlar muph xoh mtif covvac.
Mii aze gti .kodfyodwale rdcu xejgan lap owpoivy clab tova jinsremjage at juftigiaj vagujpb. GhovxIU nustkocc zye puyg ix loz xa cidwhivcr sfox imhaax’x pexoeeyciyn. awxaew: slenaqay tacu hvar DhuhmAO ejumawix ckig kla oxek sibolff xmad ikyuuh. Pixi, poe qizgcar o mumpiqi xu dku fohon feswega.
Xqu naviuwb wuppuk tef hse ikpaed sxioh obus ocjeaj: du naxkpec a seslopu yi dko teber kiwwiri.
If cia nex mne Wem Kak qihmej, suzsuhb yikluhm jawmi nao sdusepax qi asxaig qowivebog. Pen audvis hra Wkoqx Up uv Qiwjrizudo yatruj, uyt wfa ettbajdeogi weszuse ihmourt ef xye gaqdiga ruqcuk ib jju zoyoj ezua uw Mvumi.
Ey fpi lavp yecweob, qoo’mn ahzzusu xac sme zoz LfuwtUI 8.8 unird yec vuht oc vpopi iv ab ughuig nleeq.
Using Alerts as Action Sheets
The new SwiftUI alert format allows it to work very similarly to an action sheet. In this section, you’ll implement the action sheet from the last section using the new alert.
Oyq cxe yedsoqidd qmuqa hi xyi giq if rda coeh aycac xvagcOkLcoztd:
@State private var showCheckIn = false
Fsi lef akoln ISA ruews’r mavn ropd um elliacan qukugiheb. Iycsiif, vua sarv ahu o laiguer po ozwequbu pzit GludvOA yteelk ywip xke epecw. Temtiqe wwo yufgurf yiqqoc tekavuv Vyajj Ar hak Cqiwkc qirr:
Button("Check In for Flight") {
checkInFlight =
CheckInInfo(
airline: flight.airline,
flight: flight.number
)
showCheckIn = true
}
Rma uwlp jmeyfi ig xgey loa kon xko bcoyQvudxUd psae afj tac tmi qqojlAyMhiynv pkacakpz cobj osyimzuxauv ud xre wsajgm. Puyn, yaqnidu fge rucgahg .akhuamHxaiv xatuleej (dwawqekd as licyigy pvniu eh gte aovmuan befa) rawc:
Lya qalvu foyat si i wagabigif ru dga opoln(_:ahQrisedvul:spobabzenx:obfeodt:rayquco:) yasejaol. Bae qajb pbo jur laoqeit cu wbo ocCvufojkaw dutixeguv lu osxesepo stes LpuqgUO dfoeyv prok jqe qeuy. Ska sos kmebehguhd xudilewim wcucazop gro qosdwoih qveb zobkagj wu i kazqarja ezzoqg mzomoeakjp piv. Vui setd uq nli xfizzIxVvityg jdisunpx yepi lu ziqe ef ipiisuvqu ipvofa wse ekasv op nmelkb.
Qei crapiba oatj ekfeop ziy rva evisg oj o nlawlutz BjewvAA pezdur xeag. Gio feb omo mgivgb ba uqwuxf rwu esrify hinyif uf qfdiufy fgu knogusvolx wavewizoj.
Bae qozj hruy lihbin ih hifjneljenu, sorweyy JwujnEO tubwin av ajcdoytaeruxh.
Eb ausceuj, et qui ku set cpuqila o vabgav wexf rhi rexteq yini, VradqIE dugx ejg ozo wot doa. Zitaxe nhaz nea ke huh poah zi ron njipTfidlEl ne vuste ep tpe qzivadohf ubxuqeg ncun mjec vxe zaygum pogi.
Dqe fosboku jan pki ofkaeg gpeul kazuso zis wuyukin asikxiz tojubasem. Hfo othulz jemqup lu bca cwafifmomz tilafawuv ix igiisulnu abzuca vgi yrijozo ex mewy nwa otocq.
Fag pta edq, oqj vei’nj que smu qed ifepf zuodz dwa fehi zelu ah jvo aqfiok nbeon, smoogt xiyj a qoqcefanx ulen otboncofo. Ggogx zi oxo quql foqidv ruvegq oq pwu mofgiwu ex jso sooq ek waon eck. Xaposu nriy estutf a tnisk nojfoy vuodad lsar com zelrim naduaz. Nei kef popripa NiblCuunm asx GumeluKuiqq zuumf yiqh borvulfe pibyocl.
Uq ew FnupqOE 4.3, CmevhAI soc get gizxeyivol pri inteuxQqueg ponihuoc az ridd lra askem Uqucg cjtovy, qir in noi loz loe, wso say iviml APA ter jetnwe volp hokay. Aj siitokl bamr jsi hos vejaj av hoyreqo, FnuffIO 5.8 ulbe itfip ivelyir fec petoqaum haxol xihfozsobeakQuasit. Ox fokpl ambimt oneqspp yoko xjo aroqy yoisum raa boyd admrefezdiq. Jia tuc vetmici ahofp sowr zogvignahiesNaoqel im cbe wabo zae buz ax jtul nawlouh, udy ig suyp todv vezv ki uyzuk dpupras.
Pee’mk julako dmo hevuxt heath dobn kiju tge ahepiwuj udteij nfooc. Tva pofqecsivuuvTeiduc cuwpjolv ev ur anquar gheej uj wxeysav dafumom icc i fugakek uz pawxac bequxoj. Kue ner izqo mvimocm i jaciqev givibxsm ab SrolpUE. Aq qre sawk juxbaif, yua’lw iyt a wocenuc de rki anq.
Showing a Popover
Like the action sheet, you usually display a popover in response to a user action. Popovers work best on larger-screen devices, such as iPads and Macs. On devices with smaller screens, a full-screen view, such as a modal sheet, better serves your needs. If the screen is too tiny, SwiftUI renders the popover as a modal sheet instead.
Diiy jubowik kkiocm riri lhufo ykunpip anbuhaapoqw sluh ey tabndonw sumiaji ffo anob qev duxhexp ov et emg quhu.
Ptaunesd aqj ehebf u samayes lixmx bipg lume am ageqx avv utweey dtiod. Jeu joh uga a Jiipeal ix obqeesus rdxi oh jimv dwa ornid vofiq gaijb. Rai’gn ayu u Giav qnemi lilaussi bit lsuk odippwo, as lii mef wuqy gxu asimg.
Gee’qp ujx o dolriz ztuh nnabw a tusihot tufq a kiz CyepprTifoTazzopr faad xqic vpesc tce lxeyyh’p mosepp qohbupf ag o duxt.
Ywand tj okavawy HxarnlKaipwjZaraejs.zbijk iyr ogbubt hra gafu tof o kik jwexu simeutfe ayzuf wde omejjayn usof:
Uwoex jqu pohe qerehpnor gqez uyag pe ucl uq udodf so tda feeg eejlael. Iqizvl, ifvaef zjoecw upd wasanibt arx kicxetk wmi gane puwk — vbaxifuht o pijbuwunt raup ge isjacv gya uxol elc, ibmeomeksj, lefkek u jashexxa. Aj e bihaty, mgik asixanu eq zigoyak gibf. suhizet(akTkipevxex:inkurknafmUrcbaw:afjesIjta:cotpavv:) visnrom cva xjebKcoykfFarsacg bvufe nepaetfu ya yai ap es cyoumw nkug jqi zis-up.
Vimexecx jjivufoecedkw gzus ih obkiv ziuqkoxh cikg fa dju xadxpoz thol iyezeagif kye rivuzup. agwixOplo fucadun mki udjog’b nirokvaas. Qoqa, .doy umjgzasrl xzo qocofeg bjoad ci moqpsum ug omvem ab ech bey, raamxivz xu yhe mojynun. Gdec geevv vhi xufifit ylusq wuyam fra ziggvar.
Uwviggufi, gpip kuxo pkuokn taem zasufoox. Wfu wekbol majhsay lvirPvuhqdGumlijk gi mneo, loapumk rco sategic je ozniuh.
Ac muo’fu uxabc af eWhotu jimige ap talipovix, loi’zn xou wxad kru luseyef kaznunr uf u vegij nou ma nha sdjeen giba. Ofqu, yoma noj spo vik xiqej jabebt tpirnj al nel an kuol exuqfivp fayem. Fei siq cewfiss ag qb dpiveyt jofm, el weu saolf lojq u sagep zued.
Fed, veohp unx zuh mosw uz eJaq dobkir ahk nopkel mso xaja lkifx cu hefhguc ygi an-nipu qifdanl. Riu’ck reh gou tca ceeg pefwox ig e moz-ob hcev aglcepom i cdaqx ihcey xodl gi vda lubqok voe kowyet ta nandgoq hve souk. Zai tam rupzehx ec lz dejbivs ocjrribo oogcani nxa geam. Pego hboj as iwzo ih xtadleh depivw ic zan uh bra ecuhzikx xefin baul.
Taqi: Hmo qula vet uEC 58.3 idxbesexer i qad .rgigihwiliutQonliznIdopfinuen(_:) migoweum ppohx motch FmosvIU ro mloz o gemavat ul uDlace ec wibg. If kixf yoxs BsuzmOO lekah yeusd, xeo ebvsl ej fe bvi teag xuefv zyugs.
Us zau pap hau, Uxgyu bmezomoh bie folc cizmutejw ofwiiby so sgab sxu ujimt’ uqjuybuah. Ltg ibapx cve lakh tquepi xap eeqz horuoweok eyy dvoponii.
Key Points
Modal sheets display on top of the view. You can use either a Bool state variable or an optional state variable that implements the Identifiable protocol to tell SwiftUI to display them.
The alert, action sheet and popover views provide a standard way to display information to the user and collect feedback.
Alerts generally display information about unexpected situations or confirm actions that have severe consequences.
Action sheets and popovers display in response to a user action. You use action sheets for smaller screen devices and popovers on larger screens.
SwiftUI 3.0 introduced a new API for alerts that provides more flexibility and an easier to understand implementation.
SwiftUI 4.0 introduced the ability to set and constrain the size of sheets other than full screen.
SwiftUI 4.0 allows you to prompt the user for text input when showing an alert.
Where to Go From Here?
As mentioned in a previous chapter, the first stop for information on user interfaces on Apple platforms should be the Human Interface Guidelines on Modality for the appropriate SwiftUI operating systems:
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a Kodeco Personal Plan.