Search results for

column

2,061 results found

Post

Replies

Boosts

Views

Activity

How to create price change programmatically?
I'm trying to change subscription prices programmatically and found two relevant API methods: Create price change List price points The first method requires ID of price point that can be retrieved by the second one. The second method returns price points in the following format: { type : appPricePoints, id : eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ, attributes : { customerPrice : 3.99, proceeds : 2.8 }, relationships : { equalizations : { links : { self : https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ/relationships/equalizations, related : https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ/equalizations } } }, links : { self : https://api.appstoreconnect.apple.com/v3/appPricePoints/eyJzIjoiMTU2MTYxMTU2OSIsInQiOiJBRkciLCJwIjoiMTAwNDkifQ } } where ID of price point is a base64-encoded JSON with three fields: s, t, and p. I got that Price Changes are pre-created by Apple and
0
0
437
Apr ’23
NavigationSplitView hide sidebar toggle button
I'm trying to implement the same UI used by the Settings app on iPad: a split view with two columns that are visible at all times. This code produces the layout i want, but I would like to hide the toggle sidebar visibility button that the system introduces. Is there a SwiftUI API I can use to hide this button? Maybe an alternate way to setup views that tells the system that the button is not necessary? struct SomeView: View { var body: some View { NavigationSplitView( columnVisibility: .constant(.all), sidebar: { Text(sidebar) }, detail: { Text(detail) } ) .navigationSplitViewStyle(.balanced) } }
7
0
8.2k
Apr ’23
Reply to SwiftUI LazyVGrid Positioning
Hi, I saw your question a few hours ago and I don't know if you are still looking for an answer at this time. Anyways, here is the solution with an explanation for anyone who might be interested in it. You have a LazyVGrid with two columns which is what you are seeing in the screenshot you've provided. UnitView(), TemperatureView() and CurrencyView() form the first column, whereas DistanceView() and TimeView() form the second column. Since you did not specify the alignment property, it assumed its default value, which is HorizontalAlignment.center in the case of LazyVGrid. If you specify alignment as HorizontalAlignment.leading, then the view would look somewhat like how you want it to look. But, it doesn't look good because the cards are not in the middle of the screen. To solve this, you would have to embed LazyVGrid into a LazyVStack, take the CurrencyView() out of the LazyVGrid, and place it outside LazyVGrid but within LazyVStack. struct ContentView: View { let columns
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
Reply to Best way to make a grid with both top and left headers
You can definitely use Grid for this! You can do something like this: Grid{ GridRow { ForEach(0..<3) { _ in Text(header) .padding() } } ForEach(0..<3){ num in GridRow { Text((num)) .padding() ForEach(0..<2) { _ in Text(X) .padding() } } } } The first GridRow would iterate through your data for your headers. Here, I have 3 headers as I will only be using 3 columns for my data. Then, I have a ForEach that gives me 3 more GridRows. Each of these contain the label for the vertical axis label and then another ForEach that contains the data for that row. This gives you both vertical and horizontal axis labels and the data is laid out by row.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Apr ’23
NavigationSplitView and .navigationDestination
I've run into two issues using NavigationSplitView with .navigationDestination modifiers. First, programmatic navigation using .navigationDestination(isPresented: destination) does not seem to work when used in the content column of a NavigationSplitView It does, however, work from the sidebar / first column. Second, it appears that we need to add redundant .navigationDestination modifiers on iPhone and iPad to handle how NavigationSplitView is adapted when used on iPhone. Specially, when it is collapsed into a NavigationStack. Also, when an iPad UI is collapsed to a NavigationStack via Stage Manager, then expanded again, .navigationDestination modifiers in the content column seem to get lost, preventing the content list from working going forward. This somewhat explains why dynamically adding .navigationDestinations via the first column push isn't sufficient. However it results in a broken UI. Is there one location we can place .navigationDestination modifiers to work both
1
0
725
Apr ’23
Best way to make a grid with both top and left headers
Hello, I’d like to display items in a grid, with both a header row and a header column. Something like this : A B C D 1 x y x x 2 x x x x 3 x y y y 4 y x x y What elements should I use for this arrangement? It seems Grid doesn’t allow for headers that would behave differently than the data cells, and, if using a separate HStack or VStack for the headers, I’m not sure how I could force data lines and rows to stay aligned with the headers.
4
0
1.2k
Apr ’23
I wrote LazyVGrid's code, but it makes a strange move.
It's been a few months since I started Swift. Referring to the SWIFT website I wrote the code as follows. let layout2: [GridItem] = Array(repeating: .init(.flexible(minimum: 40, maximum: 75)), count: 5) let layout = [GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75)),GridItem(.fixed(75))] let layout3: [GridItem] = [GridItem(.adaptive(minimum: 70), spacing: 5)] struct ContentView: View { @State var scores: [Int] = [1,3,4,3,2, 2,3,3,4,3] var body: some View { // Text((scores.count)) = 10 // ScrollView { HStack { LazyVGrid(columns: layout, spacing: 1) { ForEach(scores, id: .self) { num in ZStack { Rectangle() .foregroundColor(.accentColor) .frame(height: 45) Text((num)) .foregroundColor(.red) } // ZStack } // ForeEach } // LazyVGrid } // HStack // } // ScrollView } // body } // ContentView struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } }language code-block The result was different from what I thought and was as follows. Th
0
0
232
Apr ’23
NavigationLink selected state area is larger than the underlying view
I'm using a NavigationSplitView with two columns for a macOS app. The sidebar column shows a list of items and the right pane shows the details for the selected item. I'm using NavigationLink to create clickable sidebar items and pass my own View-type struct that displays the row information. When I decided to add a slight background color to the rows & slight hover state, I noticed that the row view container is smaller than the NavigationLink when selected (I made the colors brighter to emphasize the issue - rows have a gray background & brighter gray hover state and blue is the built-in styling provided by NavigationLink). My code for the NavigationSplitView which lives in the body of the main ContentView: NavigationSplitView(columnVisibility: $columnVisibility) { VStack{ if userSettings.cases.isEmpty { Text(Press + to add your first case) .font(.title2) .foregroundColor(.gray) .multilineTextAlignment(.center) } else { List(userSettings.cases, selection: self.$selectedCase) { case
1
0
1.1k
Apr ’23
NavigationSplitView how to disable the side bar, to make it like the reminder app in iPad?
I want to make it like this How to disable the button that open the side bar, I only need the content and the detail view. I don't need the sidebar view. Below is my code import SwiftUI @available(iOS 16.0, *) struct Screen: View { @ObservedObject var userData = UserData() @State private var isIntroShown = true @State var Itema: Bool = false @State private var showFoodDetail = false @State var rb: Bool = false @State var Setting: Bool = false @State var Recipe: Bool = false @Environment(.defaultMinListRowHeight) var minRowHeight @Environment(.colorScheme) var colorScheme @State private var searchText = private let adaptiveColumns = [ GridItem(.adaptive(minimum: 170)) ] var columns = Array(repeating: GridItem(.flexible(), spacing: 10), count: 2) var filteredRooms: [Room] { if searchText.isEmpty { return userData.rooms } else { return userData.rooms.filter { room in let foodNames = room.food.map { $0.name.lowercased() } return room.name.lowercased().contains(searchText.lowercased()) || foodNames.conta
2
0
1.6k
Apr ’23
Reply to NavigationLink and .navigationDestination Hang and Infinite Loop
You're pushing multiple stacks that share the same path. So one stack is trying to push another stack which is trying to push the other stack.... It's a happy coincidence that ObservableObject doesn't infinite loop, I'm surprised it does not. 2 general rules will help when using the navigation system: move navigationDestination modifiers as high up in the view hierarchy. This is more efficient for the Navigation system to read up front than with potentially every view update. Don't push stacks onto stacks, and try to avoid entire NavigationStacks coming and going from the columns of a NavigationSplitView. NSV will adopt the stack and integrate its state with the state of the whole split view. I ran this example on macOS and it looked as expected import SwiftUI import OSLog final class NavigationModel: ObservableObject { @Published var path = NavigationPath() { didSet { print(navigationModel.path.count: (path.count)) } } } struct Report: Hashable { var title: String = Report Title } private let logger
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Overlaid items hide behind neighbouring views
Finally I went with something similar to what you suggested : var body: some View { GeometryReader {geometry in let size = min(geometry.size.width, geometry.size.height) let tileSize = size / 8 VStack( spacing: 0.0) { ForEach((0..<8).reversed(), id: .self) { rowIndex in HStack(spacing: 0) { ForEach((0..<8), id: .self) { columnIndex in TileView(x: rowIndex, y: columnIndex) } } } }.overlay(alignment: .bottomLeading){ ForEach(Array(model.initialState.keys), id:.self) { let (row, column) = $0.tuple() let piece = model.initialState[$0]! let offset = model.offset(piece: piece, val: tileSize) PieceView(type: piece.figure, side: piece.side) .frame(width: tileSize, height: tileSize) .offset(x: CGFloat(row) * tileSize, y: -CGFloat(column) * tileSize) .offset(offset) } } } } I thought Z Indexes are global ... then what they refer to ?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Mar ’23
Reply to Creating Floor Plan with RoomPlan
actually what you need to do is remove the y component and not the z component, if you want to convert from 3D->2D, from CapturedRoom you get dimensions.x (wall length) and (transform) .columns.3.x, transform .columns.3.z) is the coordinate of the center of the wall and the direction(transform.columns.0.z, transform.columns.0.z), is the direction of the wall, now you there is a starting and ending point of a wall, similar to other things
Topic: Spatial Computing SubTopic: ARKit Tags:
Mar ’23