-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
18 changed files
with
475 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
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,52 @@ | ||
// | ||
// TagEditView.swift | ||
// MMEX | ||
// | ||
// 2024-11-05: Edited by George Ef ([email protected]) | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct TagEditView: View { | ||
@EnvironmentObject var env: EnvironmentManager | ||
var vm: ViewModel | ||
@Binding var data: TagData | ||
@State var edit: Bool | ||
|
||
var body: some View { | ||
Section { | ||
env.theme.field.text(edit, "Name") { | ||
TextField("Cannot be empty!", text: $data.name) | ||
.textInputAutocapitalization(.words) | ||
} show: { | ||
env.theme.field.valueOrError("Cannot be empty!", text: data.name) | ||
} | ||
|
||
env.theme.field.toggle(edit, "Active") { | ||
Toggle(isOn: $data.active) { } | ||
} show: { | ||
Text(data.active ? "Yes" : "No") | ||
} | ||
} | ||
} | ||
} | ||
|
||
#Preview("\(TagData.sampleData[0].name) (show)") { | ||
let env = EnvironmentManager.sampleData | ||
Form { TagEditView( | ||
vm: ViewModel(env: env), | ||
data: .constant(TagData.sampleData[0]), | ||
edit: false | ||
) } | ||
.environmentObject(env) | ||
} | ||
|
||
#Preview("\(TagData.sampleData[0].name) (edit)") { | ||
let env = EnvironmentManager.sampleData | ||
Form { TagEditView( | ||
vm: ViewModel(env: env), | ||
data: .constant(TagData.sampleData[0]), | ||
edit: true | ||
) } | ||
.environmentObject(env) | ||
} |
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,72 @@ | ||
// | ||
// TagListView.swift | ||
// MMEX | ||
// | ||
// 2024-11-05: Edited by George Ef ([email protected]) | ||
// | ||
|
||
import SwiftUI | ||
|
||
struct TagListView: View { | ||
typealias MainData = TagData | ||
@EnvironmentObject var env: EnvironmentManager | ||
@ObservedObject var vm: ViewModel | ||
|
||
@State var search: TagSearch = .init() | ||
|
||
static let initData = TagData( | ||
active : true | ||
) | ||
|
||
var body: some View { | ||
RepositoryListView( | ||
vm: vm, | ||
vmList: vm.tagList, | ||
groupChoice: vm.tagGroup.choice, | ||
vmGroup: $vm.tagGroup, | ||
search: $search, | ||
initData: Self.initData, | ||
groupName: groupName, | ||
itemName: itemName, | ||
itemInfo: itemInfo, | ||
editView: editView | ||
) | ||
.onAppear { | ||
let _ = log.debug("DEBUG: TagListView.onAppear()") | ||
} | ||
} | ||
|
||
func groupName(_ g: Int, _ name: String?) -> some View { | ||
Text(name ?? "(unknown group name)") | ||
} | ||
|
||
func itemName(_ data: TagData) -> some View { | ||
Text(data.name) | ||
} | ||
|
||
func itemInfo(_ data: TagData) -> some View { | ||
Group { | ||
if vm.tagGroup.choice == .active { | ||
EmptyView() | ||
} else { | ||
Text(data.active ? "Active" : "Inactive") | ||
} | ||
} | ||
} | ||
|
||
func editView(_ data: Binding<MainData>, _ edit: Bool) -> some View { | ||
TagEditView( | ||
vm: vm, | ||
data: data, | ||
edit: edit | ||
) | ||
} | ||
} | ||
|
||
#Preview { | ||
let env = EnvironmentManager.sampleData | ||
TagListView( | ||
vm: ViewModel(env: env) | ||
) | ||
.environmentObject(env) | ||
} |
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
Oops, something went wrong.