Post

Replies

Boosts

Views

Activity

How can I include a function (or calculation) in the values that Charts receives to draw the chart, and overcome this bug?
Charts fails when a function or ternary condition is added to the values to be plotted. Charts. When a function is received as a value in the ForEach loop, the application crashes (Thread 1: signal SIGABRT), or if it is a ternary operator (condition ? true: false) it does not show the graph. The function should convert the value/attribute of the Core Data entity only if necessary, the data is stored in a common unit and depending on the display condition in an AppStorage variable it should be seen converted to another unit or displayed. This error occurs with any type of chart. It fails with both RulerMark and other charts like LineMark. The function works fine with Text and other similar views. The Chart @AppStorage("unitView") var unitView: String = "Celsius" ... // CHART Chart { if statsByUser.takens > 1 { RuleMark(y: .value("AVG", getViewDegrees(statsByUser.avg, unitView))) .lineStyle(StrokeStyle(lineWidth: 2, lineCap: .round, lineJoin: .round, dash: [4, 6])) .foregroundStyle(.white.opacity(0.8)) } ForEach(0..<temperatureByUserId.count, id:\.self) { item in LineMark(x: .value("Date", item + 1), y: .value("Temperature", getViewDegrees(temperatureByUserId[item].degress, unitView))) .lineStyle(.init(lineWidth: 2, lineCap: .round, lineJoin: .round)) .foregroundStyle(.white) //.mint [.pink, .purple, .mint] } .interpolationMethod(.cardinal) } // X-Axis .chartXScale(domain: 1 ... statsByUser.takens) .chartXAxis(.hidden) // Y-Axis .chartYScale(domain: statsByUser.min ... statsByUser.max) .chartYAxis { AxisMarks{ _ in AxisGridLine().foregroundStyle(.white) AxisValueLabel(centered: true).foregroundStyle(.white) } } } The Functions let unitDegress: [String] = ["Celsius", "Fahrenheit"] func getViewDegrees(_ value: Double, _ unit: String) -> Double { var returnValue = value if unit == unitDegress[1] { // is Fahrenheit let t = Measurement(value: value, unit: UnitTemperature.celsius) returnValue = t.converted(to: .fahrenheit).value } return returnValue } Text works properly. Text("\(getViewDegrees(temperatureByUser.last, unitView), specifier: decimalSpecifier)")
2
0
930
Oct ’22
SwiftUI: How to remove extra space in lists, when .deleteDisabled(true)?
I have exactly the same question, nobody has been able to solve it on Stack Overflow, so I'm going to try to get lucky here. Question Source, at: Stack Overflow - Question asked by Miosser When the ability to delete is disabled [.deleteDisabled(true)] on a list and the list's edit button [EditButton()] is pressed, the extra space to the left of each list item still appears as if it were still show the delete buttons (I don't want to do multi-selection of list rows either, just organize the list items individually), but I haven't found or been able to remove that space on the left, which belongs to the delete buttons and I want strip to make the text fill the entire line, because the stripping capability still leaves that space even if it's disabled. List { ForEach(projectListVM.projects .filter{filterFavorites ? $0.isFavorite == true : ($0.isFavorite || !$0.isFavorite)}, id: \.id) { itemProject in ProjectListRowScreen(itemProject: itemProject, projectListVM: projectListVM) } .onMove(perform: moveItem) .deleteDisabled(true) .listRowBackground(Color.clear) } ProjectListRowScreen.swift VStack(alignment: .leading) { NavigationLink { ProjectDetailScreen(projectVM: itemProject) } label: { VStack(alignment: .leading) { HStack(alignment: .top) { if itemProject.isFavorite { Image(systemName: "star.fill") .frame(width: 18, alignment: .top) .foregroundColor(Color(itemProject.color.isEmpty ? tagColors[0] : itemProject.color))//Color("Favorite")) .padding(.top, paddingMicro) } else { Image(systemName: "cube.fill") .frame(height: 18, alignment: .top) .foregroundColor(Color(itemProject.color.isEmpty ? tagColors[0] : itemProject.color)) .padding(.top, paddingMicro) } HStack(alignment: .top) { VStack(alignment: .leading) { Text(itemProject.title).fontWeight(.thin) .multilineTextAlignment(.leading) } Spacer() } } } } } .sheet(isPresented: $showEditView, onDismiss: {projectListVM.fetchAllProjects()}, content: {ProjectEditScreen(projectItem: itemProject)}) .swipeActions(edge: .leading, allowsFullSwipe: true) { Button { self.toogleFavorite(projectId: itemProject.id) } label: { if itemProject.isFavorite { Label("Unfavorite", systemImage: "star.slash") } else { Label("Favorite", systemImage: "star.fill") } } .tint(itemProject.isFavorite ? .gray: .yellow) } .swipeActions(edge: .trailing, allowsFullSwipe: true) { Button(role: .destructive) { showConfirmationDelete = true } label: { Label("Delete", systemImage: "trash") } .tint(.red) Button { showEditView = true } label: { Label("Edit",systemImage: "square.and.pencil") } .tint(.blue) } .confirmationDialog( "Are you shure? Action cannot be undone", isPresented: $showConfirmationDelete, titleVisibility: .visible, actions: { Button("Delete", role: .destructive) { withAnimation { self.deleteProjectById(projectId: itemProject.id) showConfirmationDelete = false } } Button("Cancel", role: .cancel) { showConfirmationDelete = false } }) .padding(EdgeInsets(top: 15, leading: 10, bottom: 15, trailing: 10)) .background(Color("BackgroundPanel")) .clipShape(RoundedRectangle(cornerRadius: cornerMedium, style: .continuous))
0
0
2.3k
May ’22
Failed to prepare device for development. Xcode 13.4 iOS 15.6 beta 1 iPhone X
Everything worked perfectly with Xcode 13.3.1 and iOS 15.5 beta on the iPhone X, I could run the app directly on the iPhone X (90GB free). After installing Xcode 13.4, everything continued to work perfectly, running the app directly on the iPhone X. I installed iOS 15.6 beta 1, and it shows me the following error. Failed to prepare device for development. This operation can fail if the version of the OS on the device is incompatible with the installed version of Xcode. You may also need to restart your mac and device in order to correctly detect compatibility. I completely (totally) uninstalled Xcode 13.4, and reinstalled (Xcode didn't even keep the project list open lately). I have restarted the iPhone X multiple times. How can I overcome this error without having to downgrade to iOS 15.5? I have checked the compatibility list within the Xcode.app package, yet it shows iPhone X. To get into 'Device Support' :: Open Finder -&gt; Applications -&gt; Scroll to Xcode -&gt; Right Click -&gt; Show Package Contents -&gt; Contents -&gt; Developer -&gt; Platforms -&gt; iPhoneOS.platform -&gt; DeviceSupport This is the list of devices folder support for your Xcode The app project is on iOS 15.4. Thanks in advance.
4
0
3.8k
May ’22