diff --git a/AutoRefersher/AutoRefersherApp.swift b/AutoRefersher/AutoRefersherApp.swift index c703eca..e2e1ba0 100644 --- a/AutoRefersher/AutoRefersherApp.swift +++ b/AutoRefersher/AutoRefersherApp.swift @@ -15,6 +15,11 @@ struct AutoRefersherApp: App { ContentView() } .windowStyle(HiddenTitleBarWindowStyle()) -// .windowToolbarStyle(UnifiedWindowToolbarStyle(showsTitle: false)) + .windowToolbarStyle(UnifiedWindowToolbarStyle(showsTitle: true)) } } + + +func toggleSidebar() { + NSApp.keyWindow?.firstResponder?.tryToPerform(#selector(NSSplitViewController.toggleSidebar(_:)), with: nil) +} diff --git a/AutoRefersher/ContentView.swift b/AutoRefersher/ContentView.swift index 908d6d5..3d48416 100644 --- a/AutoRefersher/ContentView.swift +++ b/AutoRefersher/ContentView.swift @@ -13,7 +13,7 @@ struct ContentView: View { let doubleFormatter = NumberFormatter() let dateFormatter = DateComponentsFormatter() - @State private var addressList: [String] = [String()] + @State var addressList: [String] = [String()] @State private var visitTimes: Double = 100 @State private var remainingTimes: Double = 100 @State private var optionMenu: Bool = false @@ -131,6 +131,14 @@ struct ContentView: View { } } .padding() +// .toolbar { +// ToolbarItem(placement: .automatic){ +// Button(action: /*@START_MENU_TOKEN@*//*@PLACEHOLDER=Action@*/{}/*@END_MENU_TOKEN@*/) { +// Image(systemName: "plus") +// .font(.largeTitle) +// } +// } +// } } } @@ -168,7 +176,7 @@ struct ContentView_Previews: PreviewProvider { } -func AllEmptyString(_ stringList: [String]) -> Bool { +fileprivate func AllEmptyString(_ stringList: [String]) -> Bool { for string in stringList { if !string.isEmpty { return false @@ -176,3 +184,17 @@ func AllEmptyString(_ stringList: [String]) -> Bool { } return true } + + +fileprivate func NonEmptyCount(_ stringList: [String]) -> Int { + var count = 0 + for string in stringList { + if !string.isEmpty { + count += 1 + } + } + if !stringList.last!.isEmpty { + count -= 1 + } + return count +} diff --git a/AutoRefersher/RecursiveTextField.swift b/AutoRefersher/RecursiveTextField.swift index 4cfcd23..0ff6d6a 100644 --- a/AutoRefersher/RecursiveTextField.swift +++ b/AutoRefersher/RecursiveTextField.swift @@ -18,10 +18,12 @@ struct RecursiveTextField: View { if !skipped { TextField(Placeholder, text: $TextList[Index], onCommit: { if !TextList[Index].isEmpty { - TextList.append(String()) + if !(TextList.last?.isEmpty ?? false) { + TextList.append(String()) + } NextRecursion = AnyView(RecursiveTextField(TextList: $TextList, Index: Index + 1, Placeholder: Placeholder)) } - else { + else if Index != TextList.count - 1 { skipped = true } })