Skip to content

Commit

Permalink
Fixed RecursiveTextField
Browse files Browse the repository at this point in the history
  • Loading branch information
Ranoiaetep committed Jan 24, 2021
1 parent 3023a2f commit 2a36dee
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
7 changes: 6 additions & 1 deletion AutoRefersher/AutoRefersherApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
26 changes: 24 additions & 2 deletions AutoRefersher/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
// }
// }
// }
}
}

Expand Down Expand Up @@ -168,11 +176,25 @@ struct ContentView_Previews: PreviewProvider {
}


func AllEmptyString(_ stringList: [String]) -> Bool {
fileprivate func AllEmptyString(_ stringList: [String]) -> Bool {
for string in stringList {
if !string.isEmpty {
return false
}
}
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
}
6 changes: 4 additions & 2 deletions AutoRefersher/RecursiveTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
})
Expand Down

0 comments on commit 2a36dee

Please sign in to comment.