How to make a sheet that is partially shown when not presented in SwiftUI? (like the one in the Shortcuts app) - ios

While many UI-elements are easy to create in SwiftUI, there´s one I'm struggling with. I don't know what it's called, but I'm talking about the bottom-search bar which turns into a full-blown sheet akin to the one shown when calling .sheet(isPresented:) when dragged up.
Here's a visual:
Screencap of the mentioned UI-element in the Shortcuts app
I realize there's a good chance this isn't possible yet, but I thought asking was worth the shot :)

Related

Detecting screen interaction outside of the component in SwiftUI

I'm building my own custom list using LazyVStack with swipeable actions thanks to this tutorial: https://prafullkumar77.medium.com/swiftui-how-to-make-custom-swipe-able-cell-727a27abdddd
It isn't half bad as long as you read through it and understand it instead of just copying and pasting. However, much like all the currently available open-source frameworks out there, it is missing a core feature that I don't know if people are just forgetting about or it's just not possible so I thought I'd ask because I can't figure it out.
In a native list in UIKit, if you drag a list item to the semi-open state and have one of the list item actions visible but then interact anywhere else in the list via drag or tap, it will dismiss the currently visible list item action. Dismissing the action is the easy part, it's telling it to dismiss which puzzles me.
I know there are many things apple can do that isn't publicly available but this does seem like something that should theoretically be possible. I'd like to figure this out and make it publicly available as these swipeable actions are a key feature apple seemingly forgot to add before deciding to move towards these lazy stacks.

How are apps with typical menu-bar-style navigation coded?

I’m a relatively new app developer working on a couple of individual projects. I’ve dumped at least one hundred hours into coding using Swift in Xcode, and, as embarrassing as it may be to admit, it seems I can’t fully grasp or find information pertaining to how popular apps such as Facebook, Instagram, YouTube, or Tinder implement non-linear view navigation via a menu bar at the bottom of the screen.
I’ve seen one particular app tutorial series that exemplifies how to go about making this menu bar style possible using a collection view of horizontally-placed views each equivalent to the size of the screen. I understand this gets rid of the issue of loading new views on top of existing old ones that sit in the background (my primary worry, outside of unnecessarily reloading information), but is this the typical method of implementing non-linear menu navigation in an app? I suppose a more pressing question at this point is “How can I go about making something like this using SwiftUI?”
If anyone can offer information, explanations, and/or sources, they would all be much appreciated. Thank you for your time!
So, upon receiving TylerTheCompiler’s comment on my post, I started researching the UITabView. It appears that this is used for creating exactly what I was trying to explain in the initial post. I subsequently searched for a way to implement this in SwiftUI and found the “tabbed view.” The tabbed view seems very easy to implement and is exactly what I’ve been looking for. I still wonder if popular applications have been utilizing the UITabBar rather than something else more practical that I am still unaware of. If you happen to know, please comment on this post — I would love to know, myself. As always, thank you for your time, everyone!

How to customize Apple CareKit?

In CareKit there are Care Card and Symptom tracker. I'm not understanding how to customize Carecardviewcontroller and symptomtrackerviewcontroller. I don't want to use these view controllers but interested in using components of these view controllers. there is no clear documentation to explore this.
(source: carekit.org)
If you are coming at this from a Swift perspective, then it has to be admitted that CareKit is about as "un-Swifty" as anything you can imagine. The GitHub site is certainly a start, but there is a horrific gap between reading the programming guides there and actually implementing a solution. It certainly has been a long slog for me!
That said, you can add customization to CareKit's story-board-free approach by using the view controller delegate functions that CareKit provides.
For example, suppose you have an app that reminds your user to perform two intervention activities, (1) take aspirin and (2) go for a brisk walk. If the user opens the Care Card and taps an event icon (one of the circles) for "take aspirin" then that will fire a method in the OCKCareCardViewControllerDelegate called:
careCardViewController(_ viewController: OCKCareCardViewController,
didSelectButtonWithInterventionEvent: OCKCarePlanEvent)
In this method you can segue to whatever view controller you'd like. E.g. if the event is for taking aspirin then display a view controller that shows a photo of an aspirin table, a reminder that it should contain just an 81 mg dose, and a recommendation about taking it with water.
Of course, nothing is ever easy with CareKit. It turns out that you will probably also want to turn off CareKit's standard practice of calling an event completed if the circle icon is tapped. That is accomplished by returning "false" from another delegate method called:
careCardViewController( _ viewController: OCKCareCardViewController,
shouldHandleEventCompletionFor
interventionActivity: OCKCarePlanActivity )
-> Bool
There is a book called Beginning CareKit Development that I can cautiously recommend. It was written for an earlier version of Swift and you have to do a lot of "translation" to get things to work with Swift 3. The last time I checked the GitHub repository for the code associated with the book was also entirely in this earlier version. APress will provide the code updated to Swift 3 if you ask. On the Kindle there are numerous little glitches with the book, including an index that has no page numbers nor hyperlinks to the associated text, very odd formatting choices that make the text sometimes hard to distinguish from code, and occasional errors in the solution code. All that said, I doubt that I'd have made any progress with CareKit without the book's help.
I've been looking for this answer myself.
As far as I researched, you can customize this screen visually with UIAppearance.
AND/OR you can create a new screen like this one from scratch using its behavior.
You can check the CareKit source code for hints on this: https://github.com/carekit-apple/CareKit/tree/master/CareKit/CareCard
There you'll notice some interesting classes/files:
OCKCareCardWeekView
OCKWeekLabelsView
OCKHeartView
OCKHeartButton
OCKWeekViewController
OCKHelpers
CareKit draws each screen via code. You can see how they do it by reading the code.
The idea is to create your own ViewController with these pieces, or one from scratch.
Surely it's not as trivial as just using CareCardViewController, but this will get you there.

Replicate iOS Pattern: Instagram Search-Style Swiping Tabs

I'm starting a new iOS project in Swift, and my experience programming native iOS applications is minimal, so please bear with me if I use some whacky terminology or overlook some simple solutions.
I'm looking to replicate a pattern in the Instagram application, as seen here:
Selected Tab
Swiping Transition
For those who don't use Instagram, what's essentially going on here is something like a UIPageViewController (with swiping functionality), but with the tabs on top indicating the selected page.
Like in Instagram, I'm planning to have this functionality within a child UIViewController of a UITabBarController (you can see the "main" tabs on the bottom).
What I started out doing was creating static tabs and adding left and right gesture recognizers to the child UIViewController, which would change the page and update the indicator of the selected page on the tabs.
This works but I'm not really loving the way it looks, nor the way it's written. I don't like the idea of needing 2 instances of the tabs, and that certainly doesn't seem to be the way Instagram is doing it, because as shown in the second image, the indicator slides between the tabs.
I've searched a fair bit, but all references to replicating Instagram patterns seem to be outdated and don't address this specific element. Like I said, though, I haven't been programming native iOS for very long (I'm an Android developer and have used Xamarin for iOS), so it's possible I'm just not using the right keywords.
I'd appreciate any help y'all can offer!
Thanks

Update status bar text colour in real time as view changes

This might be a beginner question, but I noticed something interesting in the new Apple Music app. When switching from one view to another, the status bar text colour seems to change in real time rather than all at once when the next view loads.
Check out this screen recording to see what I mean:
http://f.cl.ly/items/2A0a3Q3i2O2d2O3u3q1m/statusBar_1.mp4
Closeup: http://f.cl.ly/items/182r3n3Z1m1y0y1W0j2J/statusBar_2.mov
How would I achieve this same effect? For instance, when transitioning to another view controller modally, how would I get the status bar style to change dynamically like this rather than when the next view loads? Is it even possible? Is Apple using some private API, or is it just a really simple trick I'm missing? Sorry if this is a beginner question, but I don't think I've ever seen another app do this.
Nothing you’re missing—there’s definitely no API to do that. I’ve seen a couple of third-party apps do something similar, probably by finding the status bar window, snapshotting it, and doing clever things with the resulting image, but that’s pretty fragile. As always, if you’d like an API for something, you should file an enhancement request.

Resources