Search results for

column

2,047 results found

Post

Replies

Boosts

Views

Activity

Reply to ongoing work on Xcode Vim mode
Xcode vim mode got me really excited, but it is just missing a few commands that I depend on: . (repeat, this is crucial) Ctrl+v (column/vertical select), and Shift+I (insert in all lines of a vertical select) And to a lesser degree I also use these often: Ctrl+a, Ctrl+x (increment, decrement) :w (save because it's annoying to mentally switch between to Cmd+s) :%s///g
Sep ’22
Reply to SwiftUI Table Limit of Columns?
I am attempting to overcome the 10 columns limitation of Table This is Crashing the compiler with this error: The compiler is unable to type-check this expression in reasonable time; try breaking up the expression into distinct sub-expressions Code: import SwiftUI //--------------------------------------------------------------------------------------------- struct TestStruct : Identifiable { var id = UUID () var name : String var val : Int } //--------------------------------------------------------------------------------------------- struct ContentView: View { @State var testData : [ TestStruct ] = [ TestStruct ( name: Leopold, val: 1 ), TestStruct ( name: Napoleon, val: 2 ) ] var body: some View { VStack { Table ( testData ) { Group { TableColumn ( Name ) { testStruct in Text ( testStruct.name ) } TableColumn ( Value ) { testStruct in Text ( String ( testStruct.val ) ) } } } } } } //--------------------------------------------------------------------------------------------- struct ContentView_Pr
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Question about code in SwiftUI tutorials
A List shows a row for each item you supply, in a single column: List { Text(A List Item) Text(A Second List Item) Text(A Third List Item) } Because the example is using a list of Landmark objects, they have to be Identifiable, so there's an id parameter for each one. The syntax is saying: Go through each item in the set of Landmark objects: landmarks Create a variable we can refer to when we're using each one: landmark Add a row using the LandmarkRow view, and supply the current landmark to that view so the view can use the data. In Xcode if you put your cursor onto a variable, you'll see where else that variable is used, so if you click on landmark on the first line of code you shared, it would be highlighted in the second line, too: List(landmarks, id: .id) { >->->landmark<-<-< in LandmarkRow(landmark: >->->landmark<-<-<) }
Topic: Programming Languages SubTopic: Swift Tags:
Sep ’22
Reply to implementing form behaviour in custom inputs
iOS 16 You can use the new Grid API with a custom alignment for the labels. Grid(alignment: .leadingFirstTextBaseline) { GridRow { Text(Username:) .gridColumnAlignment(.trailing) // align the entire first column TextField(Enter username, text: $username) } GridRow { Label(Password:, systemImage: lock.fill) SecureField(Enter password, text: $password) } GridRow { Color.clear .gridCellUnsizedAxes([.vertical, .horizontal]) Toggle(Show password, isOn: $showingPassword) } } ‎ iOS 15 and earlier You can achieve this through the use of custom alignment guides and a custom view that wraps up the functionality for each row. extension HorizontalAlignment { private struct CentredForm: AlignmentID { static func defaultValue(in context: ViewDimensions) -> CGFloat { context[HorizontalAlignment.center] } } static let centredForm = Self(CentredForm.self) } struct Row { private let label: Label private let content: Content init(@ViewBuilder content: () -> Content, @ViewBuilder label: () -> Label) { self.labe
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Stop using MVVM for SwiftUI
Also, you can use FileManagement as the only SSOT. Note: File and Folder structs can be simple structs, not an active records, you do all the things in FileManagement. class FileManagement: ObservableObject { var folders: [Folder] { Folder.folders } @Published var selectedFolder: Folder? = nil var files: [File] { selectedFolder?.files ?? [] } @Published var selectedFile: File? = nil func startMonitoringChanges() // call objectWillChange.send() on changes func stopMonitoringChanges() // Folder and file operations here if needed / wanted } struct MyApp: App { @StateObject var fileManagement = FileManagement() var body: some Scene { WindowGroup { // Three-column NavigationSplitView { FolderList() } content: { FileList() } detail: { FileView() // details, attributes, preview, … } .environmentObject(fileManagement) .onAppear(perform: fileManagement.startMonitoringChanges) } } } Remember: Don’t worry about “reloading” folders and files, SwiftUI will check the differences and only update what changes. This
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Stop using MVVM for SwiftUI
// Do the operations in disk class FileManagement: ObservableObject { var folders: [Folder] = Folder.folders func createFile(…) { … } // do changes, call objectWillChange.send() func deleteFile(…) { … } // do changes, call objectWillChange.send() func setFileAsFavourite(…) { … } // do changes, call objectWillChange.send() } // Do the operations in memory class FileManagement: ObservableObject { // or class FolderStore: ObservableObject { @Published var folders: [Folder] = [] func loadFolders() { folders = Folder.folders } // or func load() { folders = Folder.folders } func createFile(…) { … } // change the folders property hierarchy func deleteFile(…) { … } // change the folders property hierarchy func setFileAsFavourite(…) { … } // change the folders property hierarchy } Also you can just use only the File and Folder active record with a FileWatcher (notify file system changes): struct File: Identifiable, Equatable, Hashable { var id: URL { url } var url: URL var name: String var date: Date var size: Int64 v
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
Reply to Stop using MVVM for SwiftUI
For an Application you can use active record for that. This works great for a lib, data access, data model. struct File: Identifiable, Equatable, Hashable { var id: UUID = UUID() var name: String var date: Date var size: Int64 var isFavourite: Bool // change attribute or reference on set / didSet func save() func delete() static var allFiles: [File] { … } static var onlyFavouriteFiles: [File] { … } } struct Folder: Identifiable { var id: UUID = UUID() var name: String var files: [File] // or computed property that fetch (on demand) files from this folder static var folders: [Folder] { … } } But in SwiftUI (declarative view layer) you can also need a state(s). You can have a FileStore, FolderStore, FileManagement, … that is part of your model. Assuming that we use system FileManager and you load the items sync when needed. class FileManagement: ObservableObject { var folders: [Folder] = Folder.folders func createFile(…) { … } // do changes, call objectWillChange.send() func deleteFile(…) { … } // do changes, c
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Sep ’22
How to add headers programmatically to NSTableView
I have created programmatically a NSTableView with a couple of columns, this table view has 3 columns and I want to set headers for the columns to accomplish the same thing as you get when you selected headers in IB. I looked for some examples, found a few things but not really work for me. How is this done. It seems like this should be easy to code. This is an example of one of the examples I found. let headerCell = CustomTableHeaderCell.init(textCell: 123123) // let font = NSFont(name: Arial, size: 22.0) // headerCell.stringValue = firstname // headerCell.font = font self.tableView.tableColumns[0].headerCell = headerCell But CustomTableHeaderCell is not found. How is this done?
Topic: UI Frameworks SubTopic: AppKit Tags:
1
0
1.1k
Aug ’22
tvOS Detecting Keyboard Type
Hi, i have to implement a grid layout for UISearchController that have different number of columns depending on users settings of keyboard (Inline or grid). At this point my layout which is on default prepared for inline keyboard, when grid appears shrinks making cells smaller. Youtube app for tvOS have this sorted out, but i struggle. Does anyone have any idea what to use?
1
0
983
Aug ’22
Reply to Create Spreadsheet Like Grid with SwiftUI
It appears that I should have been using GridItems. They have solved my problem. Below is the code: struct DateAndCloseTable: View { let containerData: [CommonAttributes] let heading: String let verticalSpacing: CGFloat = 0 let frameWidth: CGFloat = 100 let frameHeight: CGFloat = 25 let horizontalSpacing: CGFloat = 0 let trailingPadding: CGFloat = 45 let bottomPadding: CGFloat = -2 let columns = [ GridItem(.fixed(75), spacing: 0), GridItem(.fixed(75), spacing: 0) ] var body: some View { Text() Text(heading) .font(.system(size: 18, weight: .bold, design: .default)) .foregroundColor(.blue) .padding(.trailing, 24) Text() ScrollView { let lastRowIndex: Int = containerData.count - 1 LazyVGrid(columns: columns, alignment: .center, spacing: verticalSpacing){ ForEach((0...lastRowIndex), id: .self) { index in let theDate = dateToStringFormatter.string(from: containerData[index].date!) let theClose = String(format: $%.2f, containerData[index].close ) Text(theDate) .font(.system(size: 14, weig
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
macOS TableView dynamic row height?
Environment is macOS Monterey Xcode 13. Is there a way to change the behavior of a macOS NSTableView to have the row height change based on the contents of a column. As an example when populating the column data and the width of the content exceeds the width of the column to have the content wrap to an additional line, which of course the row height would have to change then as well. If so, how can this be done? Thanks
1
0
1.2k
Aug ’22
Reply to Fatal Error in ModelData at line 43
Errors thrown by the JSONDecoder contain detailed information about the line number and column number and an explanation of what failed. If you set a breakpoint at line 29, then in the debugger show the value of error.description or String(describing: error), you should see this additional information. (IIRC it's actually carried in the NSError's userInfo dictionary. Also IIRC, error.localizedDescription does not display this additional information by default.)
Aug ’22
Reply to Getting Error status code 405 while Sending PATCH request for updating in app purchases
Also I tried to create more than one in app purchase with a payload like that: { data: [{ type: inAppPurchases, attributes: { name: dummy-353535, productId: DUMMY353535, inAppPurchaseType: CONSUMABLE, reviewNote: TEST, availableInAllTerritories: true }, relationships: { app: { data: { type: apps, id: } } } }, { type: inAppPurchases, attributes: { name: dummy-663435, productId: dummy663435, inAppPurchaseType: CONSUMABLE, reviewNote: Trying to create more than one dummy, availableInAllTerritories: true }, relationships: { app: { data: { type: apps, id: } } } }] } but I get an error like that: { errors: [ { id: ffc324af-1a66-4ea8-a086-ba41ee7069de, status: 422, code: ENTITY_UNPROCESSABLE, title: The request entity is not a valid request document object, detail: Unexpected or invalid value at 'data'., meta: { position: { row: 2, column: 11 } } } ] } Can you help me about that too? I am sending requests with postman by the way
Topic: App & System Services SubTopic: StoreKit Tags:
Aug ’22