Ok, changed it to
struct ContentView: View {
var body: some View {
TabView{
Group{
List{
Text("Item 1")
Text("Item 2")
Text("Item 3")
}
}
.tabItem {
Image(systemName: "list.dash")
Text("Transactions")
}
Group{
List{
Text("Item 11")
Text("Item 12")
Text("Item 13")
}
}
.tabItem {
Image(systemName: "list.dash")
Text("Summary")
}
}.navigationTitle("Transactions")
.navigationBarBackButtonHidden(true)
}
}
and now it looks better but after switching to the other tab and back, its broken again (see clip below)
https://imgur.com/a/BfiofU1
Post
Replies
Boosts
Views
Activity
Confirmed, solution from stack overflow works perfect!
Turns out that this support document solved the issue :)
https://support.apple.com/en-ca/HT201295
Before resetting the SMC, try these steps:
Shut down your Mac.
Press and hold the power button for 10 seconds, then release the button.
Wait a few seconds, then press the power button to turn on your Mac.
Max
Ok, so I checked my actual complete code over and over again and the view where I called the PictureGallery from: turns out that that view had the variable@Environment(\.presentationMode) var presentationModeand once I commented that out, it works like a charme ...I have no idea why that would make any difference ...
And code you shall get ... 🙂ViewControllerPicture classimport SwiftUI
struct PictureGalleryDemo: View {
@ObservedObject private var pictureController: PictureController = PictureController()
var body: some View {
List(pictureController.images){ item in
Text(item.bkey)
}.onAppear{
self.pictureController.fetchPicturesByTask(bkey_issue: "XYZ", completionHandler: { success in
print(success)
})
}
}
}//
//
import Alamofire
import Combine
import Foundation
import SwiftUI
import SWXMLHash
final class PictureController: ObservableObject {
var bkey_issue: String!
var bkey: String!
var statusMessage = ""
var reference = ""
var referenceType = ""
var subProcess = ""
var mode = ""
var picture: Picture! = Picture()
@Published var images: [Picture] = []
var imageBuffer: [Picture] = []
@Published var isLoading: Bool = false {
willSet {
self.willChange.send()
}
}
@Published var statusCode: Int = 0 {
willSet {
willChange.send()
}
}
@Published var loadError: Bool = false {
willSet {
self.willChange.send()
}
}
var willChange = PassthroughSubject<Void, Never>()
private let userSettings = UserSettings()
init() {}
public func fetchPicturesByTask(bkey_issue: String, completionHandler: @escaping (Bool) -> Void) {
self.referenceType = ""
self.reference = ""
self.subProcess = "fetchPicturesByReference"
self.bkey_issue = bkey_issue
self.loadData(completionHandler: { success in
if success {
completionHandler(true)
} else {
completionHandler(false)
}
})
}
public func loadData(completionHandler: @escaping (Bool) -> Void) {
let connectionPreCheck = ConnectionPreCheck()
if !connectionPreCheck.validate() {
self.statusMessage = connectionPreCheck.statusMessage
self.loadError = true
self.isLoading = false
return
}
self.isLoading = true
self.imageBuffer = []
if self.bkey_issue == nil {
self.bkey_issue = ""
}
let feedUrl = self.userSettings.host + ":\(self.userSettings.port!)/ws/kn-getOrderByClient-V1-VS/1.0/generic?userDomain=\(self.userSettings.userDomain!)&userID=\(self.userSettings.userID!)&token=\(self.userSettings.userToken!)&process=\(self.userSettings.process!)&subProcess=\(self.subProcess)&client=\(self.userSettings.client!)&depot=\(self.userSettings.depot!)&bkey_issue=\(self.bkey_issue!)&connection=\(self.userSettings.connectionKey!)"
print(feedUrl)
var request = URLRequest(url: URL(string: feedUrl)!)
request.timeoutInterval = self.userSettings.timeout
let urlSession = URLSession.shared
let task = urlSession.dataTask(with: request, completionHandler: { (data, _, error) -> Void in
guard let data = data else {
if let error = error {
// self.connectionErrorHandler(error: error as NSError)
}
return
}
let dataString = String(data: data, encoding: .utf8)
// print(dataString)
let xml = SWXMLHash.parse(dataString!)
for elem in xml["DocumentXML"]["Message"]["Header"]["Pictures"]["Picture"].all {
let item = Picture()
item.bkey = elem["bkey"].element!.text
item.imageType = elem["imageType"].element!.text
self.imageBuffer.append(item)
}
DispatchQueue.main.async {
self.images = self.imageBuffer
completionHandler(true)
}
})
task.resume()
}
}
extension UIImage {
func toBase64() -> String? {
guard let imageData = self.pngData() else { return nil }
return imageData.base64EncodedString(options: Data.Base64EncodingOptions.lineLength64Characters)
}
}import Foundation
class Picture: Codable, Identifiable, ObservableObject {
var id = UUID()
var bkey: String!
var tmp_create: Date!
var userDomain: String!
var userID: String!
var depot: String!
var client: String!
var process: String!
var imageData: String!
var imageType: String!
var imageName: String!
var reference: String!
var referenceType: String!
init() {
}
}
Can you maybe point me in a correct direction? 🙂
Thanks, I have also tried to extend the images array with this method:var willChange = PassthroughSubject<Void, Never>()
@Published var images:[Picture] = []{
willSet{
willChange.send()
}
}to make sure that a notification is sent but that also did not work.Max
It is formatted in Xcode and I just copy & paste it here. Any other recommendations to format it besides manually indenting all the lines?
Found the issue(s):I had this piece in the codeinit(){ //nothing here }This needs to be removed, otherwise it will not ask for any variables.The other issue is the one I don't understand:private var orderStatusFromArray: [String] = ["005", "010", "022", "025", "030", "035", "040", "045", "046", "047", "060"]
private var orderStatusToArray: [String] = ["005", "010", "022", "025", "030", "035", "040", "045", "046", "047", "060"]If I change the var to let, it works as expected. Another option is to remove the private at the beginning. So it looks like as soon as you have aprivate var ...in your code, all arguments become private. Maybe I am missing something here but that seems like a bug to me.
Hi Lantua,Thanks but if you look at my example above you can see that GoodsItemFilterView also has the arrays initialized and there I can still pass the arguments so why can't I do that for the OrderHeaderFilterView?Max
Nobody an idea or having the same issue?
Hi DMG,Thanks! I was posting the question also on SO and there the feedback was to useLabelView().onAppear {
Timer.scheduledTimer(withTimeInterval: 3, repeats: false) { timer in
withAnimation(.easeInOut(duration: 2)) {
self.presentClipboardView.toggle()
}
}
}without the RunLoop.current.add(timer, forMode:RunLoop.Mode.default) So my question is: is there a specific reason to use the RunLoop or is it just a different approach?
Hi,Below the two files//
// GoodsItemFilter.swift
// WMS Toolbox
//
// Created by Max on 2020-02-05.
// Copyright © 2020 Max. All rights reserved.
//
import SwiftUI
struct GoodsItemFilterView: View {
@Environment(\.presentationMode) var presentationMode
@State var ref1Array: [String] = []
@State var ref2Array: [String] = []
@State var ref3Array: [String] = []
@State var stockStatusArray: [String] = []
@State var zoneArray: [String] = []
@State var selectorRef1 = 0
@State var selectorRef2 = 0
@State var selectorRef3 = 0
@State var selectorStockStatus = 0
@State var selectorZone = 0
var body: some View {
NavigationView {
Form{
Section(header: Text("Zone"), content: {
Picker(selection: $selectorZone, label:
Text("Zone")) {
ForEach(0 ..< zoneArray.count, id:\.self) {
Text(self.zoneArray[$0])
}
}
})
Section(header: Text("References"), content: {
Picker(selection: $selectorRef1, label:
Text("Reference 1")) {
ForEach(0 ..< ref1Array.count, id:\.self) {
Text(self.ref1Array[$0])
}
}
Picker(selection: $selectorRef2, label:
Text("Reference 2")) {
ForEach(0 ..< ref2Array.count, id:\.self) {
Text(self.ref2Array[$0])
}
}
Picker(selection: $selectorRef3, label:
Text("Reference 3")) {
ForEach(0 ..< ref3Array.count, id:\.self) {
Text(self.ref3Array[$0])
}
}
})
Section(header: Text("Status"), content: {
Picker(selection: $selectorStockStatus, label:
Text("Condition")) {
ForEach(0 ..< stockStatusArray.count, id:\.self) {
Text(self.stockStatusArray[$0])
}
}
})
Button(action: {
self.selectorZone = 0
self.selectorRef1 = 0
self.selectorRef2 = 0
self.selectorRef3 = 0
self.selectorStockStatus = 0
}, label: {
HStack(){
Spacer()
Image(systemName: "return")
Text("Reset filters")
Spacer()
}
})
}.navigationBarTitle("Filter")
.navigationBarItems(leading: (
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Text("Cancel")
}
)
), trailing: (
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Text("Done")
}
)
))
}.onAppear{
self.ref1Array.insert("***ALL***", at: 0)
self.ref2Array.insert("***ALL***", at: 0)
self.ref3Array.insert("***ALL***", at: 0)
self.stockStatusArray.insert("***ALL***", at: 0)
self.zoneArray.insert("***ALL***", at: 0)
}
}
}
struct GoodsItemFilter_Previews: PreviewProvider {
static var previews: some View {
GoodsItemFilterView(ref1Array: ["MAX100", "MAX101", "MAX102"], ref2Array: ["REF2_100", "REF2_101"], ref3Array: ["REF3_100", "REF3_101"])
}
}//
// OrderHeaderFilter.swift
// WMS Toolbox
//
// Created by Max on 2020-01-24.
// Copyright © 2020 Max. All rights reserved.
//
import SwiftUI
//import Combine
struct OrderHeaderFilterView: View {
@Environment(\.presentationMode) var presentationMode
@State var orderTypeArray: [String] = []
@State var carrierArray: [String] = []
@State var fromStatus2 = UserDefaults.standard.string(forKey: "view.orderHeaderFilter.fromStatus")
// @State private var fromStatus2 = "040"
@State private var direction = ""
@State private var fromStatus = ""
@State private var toStatus = ""
@State private var orderType = ""
@State var selectorOrderType = 0
@State var selectorCarrier = 0
@State private var selectorIndex = 1
@State private var fromStatusSelectorIndex = 6
@State private var toStatusSelectorIndex = 2
@State private var directions = ["Inbound","Outbound","Both"]
private var orderStatusFromArray: [String] = ["005", "010", "022", "025", "030", "035", "040", "045", "046", "047", "060"]
private var orderStatusToArray: [String] = ["005", "010", "022", "025", "030", "035", "040", "045", "046", "047", "060"]
@State var orderStatus = OrderStatus.s05
enum OrderStatus: String, CaseIterable, Identifiable {
case s05 = "005"
case s10 = "010"
case s22 = "022"
case s25 = "025"
case s30 = "030"
case s35 = "035"
case s40 = "040"
case s45 = "045"
case s46 = "046"
case s60 = "060"
var id: String { rawValue }
}
enum Direction: String, CaseIterable{
case outbound = "1"
case inbound = "2"
case both = "3"
init(type: String) {
switch type {
case "1": self = .outbound
case "2": self = .inbound
case "3": self = .both
default: self = .both
}
}
var text: String {
switch self {
case .outbound: return "Outbound"
case .inbound: return "Inbound"
case .both: return "Both"
}
}
}
init(){
//nothing here
}
var body: some View {
return NavigationView{
Form{
HStack{
Text("Direction")
Spacer()
Picker(selection: $direction, label:
Text("Direction")) {
ForEach(directions, id:\.self) {
status in
Text(status)
}
}
.pickerStyle(SegmentedPickerStyle())
}
Picker(selection: $fromStatus, label:
Text("From Status")) {
ForEach(orderStatusFromArray, id:\.self) {
status in
Text(status)
}
}
Picker(selection: $toStatus, label:
Text("To Status")) {
ForEach(orderStatusFromArray, id:\.self) {
status in
Text(status)
}
}
}.navigationBarTitle("Filter")
.navigationBarItems(leading: (
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Text("Cancel")
}
)
), trailing: (
Button(action: {
self.presentationMode.wrappedValue.dismiss()
}, label: {
Text("Done")
}
)
))
}.onAppear{
self.direction = UserDefaults.standard.string(forKey: "view.orderHeaderFilter.direction")!
self.fromStatus = UserDefaults.standard.string(forKey: "view.orderHeaderFilter.fromStatus")!
self.toStatus = UserDefaults.standard.string(forKey: "view.orderHeaderFilter.toStatus")!
self.orderTypeArray.insert("***ALL***", at: 0)
self.carrierArray.insert("***ALL***", at: 0)
}
}
}
struct OrderHeaderFilter_Previews: PreviewProvider {
static var previews: some View {
OrderHeaderFilterView()
}
}
Ok, I have changed it tostruct OrderHeaderFilterView: View {
@Environment(\.presentationMode) var presentationMode
@EnvironmentObject private var itemFilter: WarehouseOrderFilter
@EnvironmentObject private var settingStore: SettingStore
@State var orderTypeArray: [String] = []
@State var carrierArray: [String] = []
...but the result is still the same. When I try something likeOrderHeaderFilterView(orderTypeArray: [])I get"Argument passed to call that takes no arguments" as error.What difference does it make whether that environment object is private or not to the arguments?
If you look at macOS updates in the beta stage, the version number itself seems to remain but the build number always changes. So I am wondering if we could apply the same here?