Post

Replies

Boosts

Views

Activity

Reply to How to drag drop to reorder items in a horizontal scroll view?
The complex thing is to allow both scroll and move. I do it by using longPress for move and normal press for scrolling. Here is a code snippet: struct ContentView: View { struct Item: Identifiable { let id = UUID() var pos: Int var value: String var color: Color var onMove: Bool = false } @State var items : [Item] = [ Item(pos: 0, value: "A", color: .blue), Item(pos: 1, value: "B", color: .red), Item(pos: 2, value: "C", color: .blue), Item(pos: 3, value: "D", color: .red), Item(pos: 4, value: "E", color: .blue), Item(pos: 5, value: "F", color: .red), Item(pos: 6, value: "G", color: .blue), Item(pos: 7, value: "H", color: .red), Item(pos: 8, value: "I", color: .blue), Item(pos: 9, value: "J", color: .red), Item(pos: 10, value: "K", color: .blue)] @GestureState private var isDetectingLongPress = false @State private var completedLongPress = false @State private var activeLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 0.5) // LongPress to move, shortpress to scroll .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState activeLongPress = true } .onEnded { finished in self.activeLongPress = !finished } } var body: some View { ScrollView(.horizontal) { HStack(spacing: 5) { ForEach(items) { item in Rectangle() .fill(item.onMove ? .green : item.color) .frame(width:40, height:40) .overlay { Text("\(item.value)") } .gesture( DragGesture(minimumDistance: 2) .onChanged { _ in items[item.pos].onMove = true } .onEnded { value in let shift = Int(value.translation.width / 45) // 40 width + 5 interspace let newPos = item.pos+shift if newPos >= 0 && newPos <= 7 { let element = items.remove(at: item.pos) items.insert(element, at: newPos) items[newPos].onMove = false for itemPos in 0...7 { items[itemPos].pos = itemPos } } } ) .gesture(longPress) } } } .scrollDisabled(activeLongPress) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’25
Reply to Design Minimum Functionality
It seems that equivalent information is available on most restaurants websites. So what would be the added value of your app ? I guess that's what the rejection is based on. That's what guideline 4.2 states: 4.2 Minimum Functionality Your app should include features, content, and UI that elevate it beyond a repackaged website. If your app is not particularly useful, unique, or “app-like,” it doesn’t belong on the App Store. If your App doesn’t provide some sort of lasting entertainment value or adequate utility, it may not be accepted. Some idea: help find a restaurant close to my location where waiting time is low at some time help find where affluence limited at this time find restaurant opened at a given time (late or hourly hours)
Jan ’25
Reply to How do you make buttons inline with each other?
Welcome to the forum. Did you try to insert in a HStack ? struct NormalPageView: View { var body: some View { VStack { NavigationView { Form { Section { HStack { Image(systemName: "house.fill") Spacer() Image(systemName: "plus") Spacer() Image(systemName: "gearshape.fill") } } } } } } } If that answers your question, don't forget to close the thread by marking this answer as correct. Please note: when you post code, use code formatter tool to make it readable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jan ’25
Reply to How to drag drop to reorder items in a horizontal scroll view?
The complex thing is to allow both scroll and move. I do it by using longPress for move and normal press for scrolling. Here is a code snippet: struct ContentView: View { struct Item: Identifiable { let id = UUID() var pos: Int var value: String var color: Color var onMove: Bool = false } @State var items : [Item] = [ Item(pos: 0, value: "A", color: .blue), Item(pos: 1, value: "B", color: .red), Item(pos: 2, value: "C", color: .blue), Item(pos: 3, value: "D", color: .red), Item(pos: 4, value: "E", color: .blue), Item(pos: 5, value: "F", color: .red), Item(pos: 6, value: "G", color: .blue), Item(pos: 7, value: "H", color: .red), Item(pos: 8, value: "I", color: .blue), Item(pos: 9, value: "J", color: .red), Item(pos: 10, value: "K", color: .blue)] @GestureState private var isDetectingLongPress = false @State private var completedLongPress = false @State private var activeLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 0.5) // LongPress to move, shortpress to scroll .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState activeLongPress = true } .onEnded { finished in self.activeLongPress = !finished } } var body: some View { ScrollView(.horizontal) { HStack(spacing: 5) { ForEach(items) { item in Rectangle() .fill(item.onMove ? .green : item.color) .frame(width:40, height:40) .overlay { Text("\(item.value)") } .gesture( DragGesture(minimumDistance: 2) .onChanged { _ in items[item.pos].onMove = true } .onEnded { value in let shift = Int(value.translation.width / 45) // 40 width + 5 interspace let newPos = item.pos+shift if newPos >= 0 && newPos <= 7 { let element = items.remove(at: item.pos) items.insert(element, at: newPos) items[newPos].onMove = false for itemPos in 0...7 { items[itemPos].pos = itemPos } } } ) .gesture(longPress) } } } .scrollDisabled(activeLongPress) } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to Apple keeps preventing us for updating our app
Did you include a detailed comment to the reviewer in submission, explaining what you say here, that you have changed the screenshots to take into account the feedback you got… May be you have a new reviewer each time who does not know the context. Putting the comment may help reviewer to get it. Wish you success. PS: what type (category) of app is it ?
Replies
Boosts
Views
Activity
Jan ’25
Reply to Design Minimum Functionality
It seems that equivalent information is available on most restaurants websites. So what would be the added value of your app ? I guess that's what the rejection is based on. That's what guideline 4.2 states: 4.2 Minimum Functionality Your app should include features, content, and UI that elevate it beyond a repackaged website. If your app is not particularly useful, unique, or “app-like,” it doesn’t belong on the App Store. If your App doesn’t provide some sort of lasting entertainment value or adequate utility, it may not be accepted. Some idea: help find a restaurant close to my location where waiting time is low at some time help find where affluence limited at this time find restaurant opened at a given time (late or hourly hours)
Replies
Boosts
Views
Activity
Jan ’25
Reply to SwiftUI Architecture
How do you know the size of Facebook project ? You can use MVC if you prefer. Discussion here may be of interest: https://stackoverflow.com/questions/667781/what-is-the-difference-between-mvc-and-mvvm
Topic: Community SubTopic: Apple Developers Tags:
Replies
Boosts
Views
Activity
Jan ’25
Reply to How do you make buttons inline with each other?
Welcome to the forum. Did you try to insert in a HStack ? struct NormalPageView: View { var body: some View { VStack { NavigationView { Form { Section { HStack { Image(systemName: "house.fill") Spacer() Image(systemName: "plus") Spacer() Image(systemName: "gearshape.fill") } } } } } } } If that answers your question, don't forget to close the thread by marking this answer as correct. Please note: when you post code, use code formatter tool to make it readable.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jan ’25