-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
02806a0
commit c912b89
Showing
7 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
Lingua-App/Lingua/Lingua/Utils/Components/UI/SectionsInputView.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// | ||
// TagInputView.swift | ||
// Lingua | ||
// | ||
// Created by Egzon Arifi on 26/11/2023. | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct SectionsInputView: View { | ||
@State var currentInput: String = "" | ||
@Binding var sections: [String] | ||
|
||
var body: some View { | ||
VStack(alignment: .leading) { | ||
HStack { | ||
TextField("Enter a section", text: $currentInput, onCommit: addSection) | ||
.textFieldStyle(RoundedBorderTextFieldStyle()) | ||
.padding() | ||
|
||
Button(action: addSection) { | ||
Text("Add section") | ||
} | ||
} | ||
|
||
Divider() | ||
|
||
HStack { | ||
ForEach(sections, id: \.self) { tag in | ||
Button(action: { | ||
removeSection(tag) | ||
}, label: { | ||
Text(tag) | ||
.padding(.vertical, 4) | ||
|
||
Image(systemName: "xmark") | ||
}) | ||
} | ||
} | ||
} | ||
} | ||
|
||
private func addSection() { | ||
if !currentInput.isEmpty { | ||
sections.append(currentInput) | ||
currentInput = "" | ||
} | ||
} | ||
|
||
private func removeSection(_ tag: String) { | ||
sections.removeAll { $0 == tag } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters