SwiftUI accessibilityScrollAction not accepting rectangle edge as valid? - swiftui

So I'm trying to make an accessible game using SwiftUI, and it would be awesome to have a custom scroll action for blind users so that they don't have to swipe items using an extra set of gestures.
I'm trying to implement the scroll action on a view, but so far I've had no luck.
I have tried setting the edge to something like .leading, but it says that type Edge has no member leading. I also tried putting a . and letting it auto complete (nothing), and reading the documentation, which also gives me nothing, except that things like .leading, .top, etc should be working and are not.
.accessibilityScrollAction(handler: (.leading))
Type '(Edge) -> Void' has no member 'leading', mainView.swift, Error

Related

Programmatically activating swipeActions in a List (Similar to alarms in Clock and lists in Contacts apps)

I was looking to replicate the functionality contained in the native iOS Clock and Contacts apps for list items. After pressing "Edit" at the top right, red "minus" circles appear on the left side of each list item. If you press the minus sign, it "swipes" the list item to the right and shows the "Delete" swipeAction:
Contacts Groups List View
Contacts Groups List Edit View
Contacts Groups List Edit View - Swipe Action Active
I can set the swipeActions for a list item easily, and can replicate the edit button. As well as adding the minus buttons when editing the list (I used an HStack with a Button and Text view inside). What I cannot find anywhere is how to have the button action show the swipe action. All related posts comment on having the button action closure run the code that a gesture would typically activate. From what I understand, the gesture handling is done inside of SwiftUI itself for swipeActions, and I cannot find a way that you could imitate the result. Would this be something that would have to be done in UIKit? Or would I have to build a custom version of swipeActions to implement the same feature?
I have tried researching imitating gestures on Views, but everything seems to say it is not possible to do so

How to Order a 3 Way Tie?

I'm working on an app that involves inputting the amount of cards players ended up with, and ordering them in a list. But if theres a 2 or 3 way tie, I want the user to be able to have a menu that lets them select the order of who had the highest card to lowest card, that way I can organize the list. How do I get the user to order them, like what kind of Alert/Popup lets me do that?
Edit: Basically I was asking how to make a picker that lets you arrange multiple items into a specific order but it seems the best thing to do is just to have a stack appear with buttons for each item, where you can click them and go from there to create your order. Hope this helps for anyone in a similar situation!
For that kind of user interaction where they are doing more than just tapping an option (in your case, you want them to order the various cards), I would create your own custom view rather than use an alert or action sheet or similar.
The way you implement will depend on how you want it to look. If you want the view to appear on top of your current view (a bit like an alert does) where it only takes up the space needed for the content) then you can embed in a zStack. If you want it to slide up from the bottom as almost the same size as the full screen then you can use a sheet (sometimes also referred to as a modal).
A little difficult to explain how they look visually - if you google image search “SwiftUI sheet” then you’ll see what I mean (if you aren’t already familiar with them)
ZStack
you put your current view in a ZStack then create a new view which goes in the ZStack after it but you wrap it in an if statement so it’s conditionally shown based on a Boolean being true.
E.g.
if gameTied { ChooseSortOrderView() }
then when your game finishes - if it’s a tie, you set your Boolean to true and up pops the new view.
You can pass in the tied cards, get the user to sort them via drag and drop, form, picker (whatever you want), submit it. Then set the bool back to false to make the view go away.
sheet
The other alternative instead of using a zstack would be sheet so you get a modal view appear. Similar approach but instead of the ZStack, you use a .sheet modifier.

Using a longPressAction within a List and NavigationLink

Unlike in UIKit, where a LongPressGesture is actually delayed, in SwiftUI it began as soon as you hover/pan/touch the view. So if you have a LongPressGesture/Action in a View within a List or a NavigationLink, it'll prevent scrolling the List, or triggering the NavigationLink action.
Anyone have any idea if it's possible to delay it with current API?

Is is possible to create a tabbarcontroller that does not have elements hidden within "More" section?

I'm currently running into issues similar to the ones described in this post and am wondering if it is possible in a tabbarcontroller to not show the "More" icon and display all of the view controllers in the tab bar?
The issue of reconciling the show and hide becomes problematic if I assume that some views have navigation bars and that a user may change the order of the tabs, so hiding and showing tab bars becomes another facet of the project I will need to keep track of in appearance and disappearance methods.
Per Apple's documentation, the morenavigationcontroller is something that does not is set in the tabbar's vc array, but is merely a property

Disable only specific list items in a win32 ListView

I am using win32, c++.
I have a ListView & i want to disable (grey out) only some of the items from the list.
Is that possible or only whole ListView can be greyed out?
The ListView control does not have a concept of disabled items. You can simulate that appearance using custom drawing support. This Sample demonstrates how to change the text and background color of items within the list view.
You would need to go further and provide some means of determining when a disabled item is selected within the view (as the selection will continue to work).
The Windows List View Common Control does not have a disabled state for Items. If you want to do that, you will have to implement it yourself.
This is a not-trivial exercise. It's not hard to change the visible appearance using customer draw, but handling hit-testing and selection would be quite complex.