SwiftUI Toasts | Xcode 16

  Рет қаралды 4,412

Kavsoft

Kavsoft

Күн бұрын

Пікірлер: 17
@Kavsoft
@Kavsoft Ай бұрын
Inspiration 👇 x.com/emilkowalski_/status/1818747624088125509?s=46
@fengye4917
@fengye4917 Ай бұрын
great job
@yq_dev
@yq_dev Ай бұрын
Long time no see, like your video , respect!!!
@nitinbhatia493
@nitinbhatia493 Ай бұрын
nice work
@DEV_XO
@DEV_XO Ай бұрын
🔥🔥🔥
@linhta2546
@linhta2546 Ай бұрын
Thank you for the amazing work! I wonder if there is a way to scroll the VStack when expanded in case there are too many items. I tried wrapping it in scroll view but the transition from ZStack to VStack doesn't look good
@Kavsoft
@Kavsoft Ай бұрын
You can definitely change its behaviour to adapt into a scroll view, just make the following changes to the code, 1. Create a State variable called “height”, @State private var height: CGFloat = .zero 2. Now Wrap the layout { … } into a ScrollView, ScrollView(.vertical) { layout { … } } 3. Remove the onTapGesture from both the background and the layout instance. 4. Add the following lines of code in the respective places, a. Add these lines to the ScrollView, ScrollView { … } .rotationEffect(.init(degrees: 180)) .frame(height: isExpanded ? nil : height == 0 ? nil : height) .scrollClipDisabled() .scrollIndicators(.hidden) .scrollDisabled(!isExpanded) .allowsHitTesting(!toasts.isEmpty) .onTapGesture { isExpanded.toggle() } b. Add these lines to the layout (Inside the ScrollView), ScrollView(.vertical) { layout { … } .rotationEffect(.init(degrees: -180)) .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { newValue in height = newValue } } 5. Modify the DragGesture() to the following, DragGesture(minimumDistance: 30, coordinateSpace: .global) Also modify the xOffset to the following, let xOffset = value.translation.width < 0 ? value.translation.width + 20 : 0 6. Finally change all the instances of the bouncy animation to .snappy(duration: 0.3, extraBounce: 0) animation, since bouncy animation will have some bounce glitches with the scrollviews. By doing these steps, you can convert the toasts VStack into a ScrollView. Have a great day!
@user32352
@user32352 Ай бұрын
does this work on the root level or only the screen you are on? if toast pops up and you navigate to a new page is it still visible?
@nitinbhatia493
@nitinbhatia493 Ай бұрын
same question I have too
@Kavsoft
@Kavsoft Ай бұрын
Nope, this is more like per view context basis. Each view will have its separate toasts, but I do have a video that will create universal toasts and display at the top of the SwiftUI app. For more, check this video out, kzbin.info/www/bejne/mGeph4KOj7lridE
@Kavsoft
@Kavsoft Ай бұрын
Additionally, I got many people asking this, so I will try to add a new version of code in my Patreon that will work like a universal toast!
@Kavsoft
@Kavsoft Ай бұрын
I added a version that will work as a universal toast also with enabled scroll actions; check out the code in the patreon (link in the description).
@nitinbhatia493
@nitinbhatia493 Ай бұрын
❤ that so fast, will launch a video for that too ?
@luunguyen8295
@luunguyen8295 Ай бұрын
How about the case when there're many toasts in VStackLayout and we need a ScrollView for it, can you help me build it?
@Kavsoft
@Kavsoft Ай бұрын
You can definitely change its behaviour to adapt into a scroll view, just make the following changes to the code, 1. Create a State variable called “height”, @State private var height: CGFloat = .zero 2. Now Wrap the layout { … } into a ScrollView, ScrollView(.vertical) { layout { … } } 3. Remove the onTapGesture from both the background and the layout instance. 4. Add the following lines of code in the respective places, a. Add these lines to the ScrollView, ScrollView { … } .rotationEffect(.init(degrees: 180)) .frame(height: isExpanded ? nil : height == 0 ? nil : height) .scrollClipDisabled() .scrollIndicators(.hidden) .scrollDisabled(!isExpanded) .allowsHitTesting(!toasts.isEmpty) .onTapGesture { isExpanded.toggle() } b. Add these lines to the layout (Inside the ScrollView), ScrollView(.vertical) { layout { … } .rotationEffect(.init(degrees: -180)) .onGeometryChange(for: CGFloat.self) { $0.size.height } action: { newValue in height = newValue } } 5. Modify the DragGesture() to the following, DragGesture(minimumDistance: 30, coordinateSpace: .global) Also modify the xOffset to the following, let xOffset = value.translation.width < 0 ? value.translation.width + 20 : 0 6. Finally change all the instances of the bouncy animation to .snappy(duration: 0.3, extraBounce: 0) animation, since bouncy animation will have some bounce glitches with the scrollviews. By doing these steps, you can convert the toasts VStack into a ScrollView. Have a great day!
@danielcrompton7818
@danielcrompton7818 Ай бұрын
Please explain the asymmetric transition at 7:36
@Kavsoft
@Kavsoft Ай бұрын
It means that the view transitions will have two transitions, one for insertion and one for removal. For example, I can use this to push the view from the top when it’s inserted and slide it in the leading side when it’s removed.
Auto Scrolling Infinite Carousel - iOS 18 - Xcode 16
13:05
Kavsoft
Рет қаралды 2,9 М.
SwiftUI App Theme Switcher - iOS 17 & 18
16:20
Kavsoft
Рет қаралды 4 М.
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 13 МЛН
Миллионер | 3 - серия
36:09
Million Show
Рет қаралды 2 МЛН
Getting the MOST out of Xcode 16
24:52
Stewart Lynch
Рет қаралды 6 М.
SwiftUI - Reorder a List (2 Ways)
13:33
Sean Allen
Рет қаралды 7 М.
Play: The Secret Weapon for iOS Devs & Designers
10:12
Sean Allen
Рет қаралды 35 М.
Grid Multi-Selection using Pan Gesture | SwiftUI
20:26
Kavsoft
Рет қаралды 2,1 М.
Enhance App UI Animations with these 4 Modifiers
5:45
Kavsoft
Рет қаралды 4,9 М.
DRM explained - How Netflix prevents you from downloading videos?
18:17
Mehul - Codedamn
Рет қаралды 225 М.
SwiftUI Animated Toasts | HUDs | Xcode 15
15:41
Kavsoft
Рет қаралды 9 М.
SwiftUI Login and Sign-Up Screen with animation
23:51
SuCodee
Рет қаралды 2,1 М.
SwiftUI Scrollable Tab Bar - iOS 17
10:49
Kavsoft
Рет қаралды 9 М.