Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hugo/feature/Use double sheet when navigating into sheets #743

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ struct EditCaregiverView: View {
}

Section {
self.professionNavigationLink
self.professionPickerButton
}

Section {
Expand Down Expand Up @@ -72,6 +72,7 @@ struct EditCaregiverView: View {
@ObservedObject private var rootOwnerViewModel: RootOwnerViewModel = .shared
@ObservedObject private var styleManager: StyleManager = .shared
@State private var isAvatarPickerPresented: Bool = false
@State private var isProfessionPickerPresented: Bool = false

private var avatarPickerButton: some View {
Button {
Expand All @@ -83,19 +84,26 @@ struct EditCaregiverView: View {
.font(.headline)
}
}
.navigationDestination(isPresented: self.$isAvatarPickerPresented) {
.sheet(isPresented: self.$isAvatarPickerPresented) {
AvatarPicker(avatar: self.$modifiedCaregiver.avatar)
}
.frame(maxWidth: .infinity, alignment: .center)
}

private var professionNavigationLink: some View {
private var professionPickerButton: some View {
VStack(alignment: .leading) {
NavigationLink {
ProfessionPicker(caregiver: self.$modifiedCaregiver)
} label: {
Text(l10n.CaregiverCreation.professionLabel)
.font(.body)
LabeledContent(String(l10n.CaregiverCreation.professionLabel.characters)) {
Button {
self.isProfessionPickerPresented = true
} label: {
Image(systemName: "plus")
}
.sheet(isPresented: self.$isProfessionPickerPresented) {
NavigationStack {
ProfessionPicker(caregiver: self.$modifiedCaregiver)
.navigationBarTitleDisplayMode(.inline)
}
}
}

if !self.modifiedCaregiver.professions.isEmpty {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct EditCarereceiverView: View {
.font(.headline)
}
}
.navigationDestination(isPresented: self.$isAvatarPickerPresented) {
.sheet(isPresented: self.$isAvatarPickerPresented) {
AvatarPicker(avatar: self.$modifiedCarereceiver.avatar)
}
.frame(maxWidth: .infinity, alignment: .center)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ struct ProfessionPicker: View {

// MARK: Private

@State private var otherProfessionText: String = ""
@State private var selectedProfessions: Set<Profession> = []
@State private var selectedProfessionForDetails: Profession?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct CreateCaregiverView: View {
}

Section {
self.professionNavigationLink
self.professionPickerButton
}

Button(String(l10n.CaregiverCreation.registerProfilButton.characters)) {
Expand Down Expand Up @@ -67,6 +67,7 @@ struct CreateCaregiverView: View {

@ObservedObject private var rootOwnerViewModel = RootOwnerViewModel.shared
@State private var isAvatarPickerPresented: Bool = false
@State private var isProfessionPickerPresented: Bool = false

private var avatarPickerButton: some View {
Button {
Expand All @@ -78,20 +79,27 @@ struct CreateCaregiverView: View {
.font(.headline)
}
}
.navigationDestination(isPresented: self.$isAvatarPickerPresented) {
AvatarPicker(avatar: self.$newCaregiver.avatar)
.sheet(isPresented: self.$isAvatarPickerPresented) {
NavigationStack {
AvatarPicker(avatar: self.$newCaregiver.avatar)
}
}
.frame(maxWidth: .infinity, alignment: .center)
}

private var professionNavigationLink: some View {
private var professionPickerButton: some View {
VStack(alignment: .leading) {
NavigationLink {
ProfessionPicker(caregiver: self.$newCaregiver)
Button {
self.isProfessionPickerPresented = true
} label: {
Text(l10n.CaregiverCreation.professionLabel)
.font(.body)
}
.sheet(isPresented: self.$isProfessionPickerPresented) {
NavigationStack {
ProfessionPicker(caregiver: self.$newCaregiver)
}
}

if !self.newCaregiver.professions.isEmpty {
ForEach(self.newCaregiver.professions, id: \.self) { id in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,11 @@ struct CreateCarereceiverView: View {
.font(.headline)
}
}
.navigationDestination(isPresented: self.$isAvatarPickerPresented) {
AvatarPicker(avatar: self.$newCarereceiver.avatar)

.sheet(isPresented: self.$isAvatarPickerPresented) {
NavigationStack {
AvatarPicker(avatar: self.$newCarereceiver.avatar)
}
}
.frame(maxWidth: .infinity, alignment: .center)
}
Expand Down
37 changes: 34 additions & 3 deletions Tools/Hooks/check_yaml_content_activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,29 @@ def check_strings_for_newline(data, path=None):
return keys_with_newlines


def check_empty_strings(data, path=None):
"""Check for empty strings in the data structure"""
if path is None:
path = []
violations = []

if isinstance(data, dict):
for key, value in data.items():
sub_path = path + [key] # Build the path for nested dictionaries
if isinstance(value, str) and (value == "" or value.isspace()):
violations.append("/".join(map(str, sub_path)))
else:
# Recurse into the value if it's a dict or list
violations += check_empty_strings(value, sub_path)
elif isinstance(data, list):
for index, item in enumerate(data):
sub_path = path + [str(index)] # Handle list indexing in the path
# Recurse into the item if it's a dict or list
violations += check_empty_strings(item, sub_path)

return violations


def create_yaml_object():
"""Create a YAML object"""
yaml = ruamel.yaml.YAML(typ="rt")
Expand Down Expand Up @@ -177,9 +200,10 @@ def check_content_activity(filename):
minutes=1
)
if last_edited_at < one_minute_ago:
print(f"\n❌ last_edited_at in {filename} is not up to date")
print(f"last_edited_at: {last_edited_at}")
print(f"Update last_edited_at: {DATE_NOW_TIMESTAMP}")
print(
f"\n❌ last_edited_at {last_edited_at} is not up to date in {filename}"
)
print(f"Update last_edited_at: {DATE_NOW_TIMESTAMP}\n")
data["last_edited_at"] = DATE_NOW_TIMESTAMP
with open(filename, "w", encoding="utf8") as file:
yaml.dump(data, file)
Expand Down Expand Up @@ -229,6 +253,13 @@ def check_content_activity(filename):
print(f"❌ String staring with newline for key: {string} \nin {filename}\n")
file_is_valid = False

# ? Check for empty strings according to the JTD schema
# schema = load_jtd_schema(JTD_SCHEMA)
empty_strings = check_empty_strings(data)
for string in empty_strings:
print(f"❌ Empty string for key: {string} \nin {filename}\n")
file_is_valid = False

return file_is_valid


Expand Down