Skip to content

Commit

Permalink
Update rows for UversizeUI 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
aromanov91 committed Jun 29, 2023
1 parent 89a7561 commit 2cf0dca
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 80 deletions.
31 changes: 14 additions & 17 deletions Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,25 @@ public struct CreateEventView: View {
})
}
.trailingBar {
if viewModel.title.isEmpty {
BarButton(.disabled(L10n.Button.save))
} else {
BarButton(.accent(L10n.Button.save, action: {
switch viewModel.type {
case .new:
BarButton(.accent(L10n.Button.save, action: {
switch viewModel.type {
case .new:
Task {
_ = await viewModel.save()
dismiss()
}
case .update:
if viewModel.span == nil, viewModel.repitRule != .never {
viewModel.present(.span)
} else {
Task {
_ = await viewModel.save()
dismiss()
}
case .update:
if viewModel.span == nil, viewModel.repitRule != .never {
viewModel.present(.span)
} else {
Task {
_ = await viewModel.save()
dismiss()
}
}
}
}))
}
}
}))
.disabled(viewModel.title.isEmpty)
}
.titleLabel {
Button { viewModel.present(.calendar) } label: {
Expand Down
15 changes: 6 additions & 9 deletions Sources/OversizeCalendarKit/Pickers/RepeatPicker.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,12 @@ public struct RepeatPicker: View {
BarButton(.close)
}
.trailingBar {
if rule == .never {
BarButton(.disabled("Done"))
} else {
BarButton(.accent("Done", action: {
selectionRule = rule
selectionEndRule = endRule
dismiss()
}))
}
BarButton(.accent("Done", action: {
selectionRule = rule
selectionEndRule = endRule
dismiss()
}))
.disabled(rule == .never)
}
.surfaceContentRowInsets()
}
Expand Down
16 changes: 7 additions & 9 deletions Sources/OversizeContactsKit/AttendeesList/AttendeesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,15 @@ public struct AttendeesView: View {
if let attendees = viewModel.event.attendees {
VStack(spacing: .zero) {
if let organizer = viewModel.event.organizer {
Row(organizer.name ?? organizer.url.absoluteString, subtitle: "Organizer")
.rowLeading(.view(AnyView(
userAvatarView(participant: organizer)
)))
Row(organizer.name ?? organizer.url.absoluteString, subtitle: "Organizer") {
userAvatarView(participant: organizer)
}
}

ForEach(attendees, id: \.self) { attender in
Row(attender.name ?? attender.url.absoluteString, subtitle: attender.participantRole.title)
.rowLeading(.view(AnyView(
userAvatarView(participant: attender)
)))
Row(attender.name ?? attender.url.absoluteString, subtitle: attender.participantRole.title) {
userAvatarView(participant: attender)
}
}
}
}
Expand All @@ -83,7 +81,7 @@ public struct AttendeesView: View {
.fillBackgroundPrimary()
}
Image(systemName: participant.symbolName)
.foregroundOnPrimaryHighEmphasis()
.onPrimaryHighEmphasisForegroundColor()
.font(.system(size: 9, weight: .black))
}
}
Expand Down
20 changes: 12 additions & 8 deletions Sources/OversizeContactsKit/ContactsLists/ContactsListsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ public struct ContactsListsView: View {
}
}
} else {
Row(email)
.rowLeading(.avatar(Avatar(firstName: email)))
Row(email) {
Avatar(firstName: email)
}
}
}
}
Expand All @@ -66,19 +67,22 @@ public struct ContactsListsView: View {
private func emailRow(email: CNLabeledValue<NSString>, contact: CNContact) -> some View {
let email = email.value as String
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
Row(contact.givenName + " " + contact.familyName, subtitle: email)
.rowLeading(.avatar(Avatar(firstName: contact.givenName, lastName: contact.familyName, avatar: Image(uiImage: avatarThumbnail))))
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName, avatar: Image(uiImage: avatarThumbnail))
}
} else {
Row(contact.givenName + " " + contact.familyName, subtitle: email)
.rowLeading(.avatar(Avatar(firstName: contact.givenName, lastName: contact.familyName)))
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName)
}
}
}

@ViewBuilder
private func placeholder() -> some View {
ForEach(emails, id: \.self) { email in
Row(email)
.rowLeading(.avatar(Avatar(firstName: email)))
Row(email) {
Avatar(firstName: email)
}
}
}
}
70 changes: 43 additions & 27 deletions Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,10 @@ public struct EmailPickerView: View {
BarButton(.close)
}
.trailingBar {
if selectedEmails.isEmpty, !viewModel.searchText.isEmail {
BarButton(.disabled("Done"))
} else {
BarButton(.accent("Done", action: {
onDoneAction()
}))
}
BarButton(.accent("Done", action: {
onDoneAction()
}))
.disabled(selectedEmails.isEmpty && !viewModel.searchText.isEmail)
}
.topToolbar {
TextField("Email or name", text: $viewModel.searchText)
Expand Down Expand Up @@ -77,10 +74,15 @@ public struct EmailPickerView: View {
@ViewBuilder
private func newEmailView() -> some View {
if !viewModel.searchText.isEmpty {
Row(viewModel.searchText, subtitle: "New member")
.rowLeading(.avatar(Avatar(firstName: viewModel.searchText)))
.rowTrailing(.checkbox(isOn: .constant(viewModel.searchText.isEmail)))
.padding(.bottom, .small)
Checkbox(
isOn: .constant(viewModel.searchText.isEmail),
label: {
Row(viewModel.searchText, subtitle: "New member") {
Avatar(firstName: viewModel.searchText)
}
}
)
.padding(.bottom, .small)
}
}

Expand All @@ -92,7 +94,7 @@ public struct EmailPickerView: View {
Spacer()
}
.title3()
.foregroundOnSurfaceMediumEmphasis()
.onSurfaceMediumEmphasisForegroundColor()
.padding(.vertical, .xxSmall)
.paddingContent(.horizontal)

Expand All @@ -106,11 +108,17 @@ public struct EmailPickerView: View {
}
} else {
let isSelected = selectedEmails.contains(email)
Row(email) {
onContactClick(email: email)
}
.rowLeading(.avatar(Avatar(firstName: email)))
.rowTrailing(.checkbox(isOn: .constant(isSelected)))
Checkbox(
isOn: Binding(
get: { isSelected },
set: { _ in onContactClick(email: email) }
),
label: {
Row(email) {
Avatar(firstName: email)
}
}
)
}
}
}
Expand Down Expand Up @@ -145,17 +153,25 @@ public struct EmailPickerView: View {
let email = email.value as String
let isSelected = selectedEmails.contains(email)
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
onContactClick(email: email)
}
.rowLeading(.avatar(Avatar(firstName: contact.givenName, lastName: contact.familyName, avatar: Image(uiImage: avatarThumbnail))))
.rowTrailing(.checkbox(isOn: .constant(isSelected)))
Checkbox(isOn: Binding(
get: { isSelected },
set: { _ in onContactClick(email: email) }
), label: {
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName, avatar: Image(uiImage: avatarThumbnail))
}

})
} else {
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
onContactClick(email: email)
}
.rowLeading(.avatar(Avatar(firstName: contact.givenName, lastName: contact.familyName)))
.rowTrailing(.checkbox(isOn: .constant(isSelected)))
Checkbox(isOn: Binding(
get: { isSelected },
set: { _ in onContactClick(email: email) }
), label: {
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName)
}

})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,21 +233,15 @@ import SwiftUI
.premium()
.onPremiumTap()

//Switch(isOn: theme.$borderApp) {
Switch(isOn: theme.$borderApp) {
Row("Borders") {
pageDestenation = .border
} leading: {
borderIcon
} trailing: {
Toggle("", isOn: theme.$borderApp)
.labelsHidden()
.disabled(!isPremium)
}
.premium()
.onPremiumTap()

// }

}
.onPremiumTap()
// Row("Borders", leadingType: .image(borderIcon), trallingType: .toggleWithArrowButton(isOn: theme.$borderApp, action: {
// pageDestenation = .border
// })) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@ import SwiftUI
Switch(isOn: $settingsService.blurMinimizeEnabend) {
Row(L10n.Security.blurMinimize)
.premium()

}
.onPremiumTap()
}
Expand Down

0 comments on commit 2cf0dca

Please sign in to comment.