Skip to content

Commit

Permalink
Develop (#15)
Browse files Browse the repository at this point in the history
Format and HealtKit error support
  • Loading branch information
aromanov91 authored Mar 31, 2024
1 parent 8976a70 commit 430af61
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 77 deletions.
2 changes: 1 addition & 1 deletion AppExample/Example/Router/Alerts.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//

import OversizeLocalizable
import OversizeModels
import OversizeServices
import SwiftUI
import OversizeModels

enum RootAlert: Identifiable {
case dismiss(_ action: () -> Void)
Expand Down
46 changes: 23 additions & 23 deletions Sources/OversizeCalendarKit/CreateEventScreen/CreateEventView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public struct CreateEventView: View {
Button { viewModel.present(.calendar) } label: {
HStack(spacing: .xxxSmall) {
Circle()
.fill(Color(viewModel.calendar?.cgColor ?? CGColor.init(red: 0.4, green: 0.4, blue: 0.4, alpha: 1)))
.fill(Color(viewModel.calendar?.cgColor ?? CGColor(red: 0.4, green: 0.4, blue: 0.4, alpha: 1)))
.frame(width: 16, height: 16)
.padding(.xxxSmall)

Expand Down Expand Up @@ -150,27 +150,27 @@ public struct CreateEventView: View {
.scrollContentBackground(.hidden)
.background {
#if os(iOS)
RoundedRectangleCorner(radius: 4, corners: [.bottomLeft, .bottomRight])
.fillSurfaceSecondary()
.overlay(alignment: .topLeading) {
if viewModel.note.isEmpty {
Text("Note")
.body(.medium)
.onSurfaceDisabledForegroundColor()
.padding(.small)
RoundedRectangleCorner(radius: 4, corners: [.bottomLeft, .bottomRight])
.fillSurfaceSecondary()
.overlay(alignment: .topLeading) {
if viewModel.note.isEmpty {
Text("Note")
.body(.medium)
.onSurfaceDisabledForegroundColor()
.padding(.small)
}
}
}
#else
RoundedRectangle(cornerRadius: .small)
.fillSurfaceSecondary()
.overlay(alignment: .topLeading) {
if viewModel.note.isEmpty {
Text("Note")
.body(.medium)
.onSurfaceDisabledForegroundColor()
.padding(.small)
RoundedRectangle(cornerRadius: .small)
.fillSurfaceSecondary()
.overlay(alignment: .topLeading) {
if viewModel.note.isEmpty {
Text("Note")
.body(.medium)
.onSurfaceDisabledForegroundColor()
.padding(.small)
}
}
}
#endif
}
.frame(minHeight: 76)
Expand All @@ -183,11 +183,11 @@ public struct CreateEventView: View {
.padding(.vertical, 18)
.background {
#if os(iOS)
RoundedRectangleCorner(radius: 4, corners: [.topLeft, .topRight])
.fillSurfaceSecondary()
RoundedRectangleCorner(radius: 4, corners: [.topLeft, .topRight])
.fillSurfaceSecondary()
#else
RoundedRectangle(cornerRadius: .small)
.fillSurfaceSecondary()
RoundedRectangle(cornerRadius: .small)
.fillSurfaceSecondary()
#endif
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,23 @@ public extension CreateEventView {
switch sheet {
case .startTime:
#if os(iOS)
DatePickerSheet(title: "Starts time", selection: $viewModel.dateStart)
.onDisappear {
if viewModel.dateStart > viewModel.dateEnd {
viewModel.dateEnd = viewModel.dateStart.halfHour
DatePickerSheet(title: "Starts time", selection: $viewModel.dateStart)
.onDisappear {
if viewModel.dateStart > viewModel.dateEnd {
viewModel.dateEnd = viewModel.dateStart.halfHour
}
}
}
.presentationDetents([.height(500)])
.presentationDetents([.height(500)])
#else
EmptyView()
EmptyView()
#endif
case .endTime:
#if os(iOS)
DatePickerSheet(title: "Ends time", selection: $viewModel.dateEnd)
.datePickerMinimumDate(viewModel.dateStart.minute)
.presentationDetents([.height(500)])
DatePickerSheet(title: "Ends time", selection: $viewModel.dateEnd)
.datePickerMinimumDate(viewModel.dateStart.minute)
.presentationDetents([.height(500)])
#else
EmptyView()
EmptyView()
#endif
case .attachment:
AttachmentView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ public struct ContactsListsView: View {
private func emailRow(email: CNLabeledValue<NSString>, contact: CNContact) -> some View {
let email = email.value as String
#if os(iOS)
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName, avatar: Image(uiImage: avatarThumbnail))
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
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) {
Avatar(firstName: contact.givenName, lastName: contact.familyName)
}
}
} else {
#else
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName)
}
}
#else
Row(contact.givenName + " " + contact.familyName, subtitle: email) {
Avatar(firstName: contact.givenName, lastName: contact.familyName)
}
#endif
}

Expand Down
46 changes: 23 additions & 23 deletions Sources/OversizeContactsKit/ContactsPicker/EmailPickerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public struct EmailPickerView: View {
TextField("Email or name", text: $viewModel.searchText)
.textFieldStyle(DefaultPlaceholderTextFieldStyle())
.focused($isFocusSearth)
#if os(iOS)
#if os(iOS)
.keyboardType(.emailAddress)
#endif
#endif
}
.onAppear {
isFocusSearth = true
Expand Down Expand Up @@ -154,17 +154,28 @@ public struct EmailPickerView: View {
let email = email.value as String
let isSelected = selectedEmails.contains(email)
#if os(iOS)
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
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))
}
if let avatarThumbnailData = contact.thumbnailImageData, let avatarThumbnail = UIImage(data: avatarThumbnailData) {
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 {
})
} else {
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)
}

})
}
#else
Checkbox(isOn: Binding(
get: { isSelected },
set: { _ in onContactClick(email: email) }
Expand All @@ -174,17 +185,6 @@ public struct EmailPickerView: View {
}

})
}
#else
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)
}

})
#endif
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@ public struct PremiumBlockOverlay: ViewModifier {
let subtitle: String?

private let closeAction: (() -> Void)?


public init(isShow: Binding<Bool> = .constant(true), title: String, subtitle: String?, closeAction: (() -> Void)? = nil) {
self._isShow = isShow
_isShow = isShow
self.title = title
self.subtitle = subtitle
self.closeAction = closeAction
}

public func body(content: Content) -> some View {
if !isPremium && isShow {
if !isPremium, isShow {
ZStack {
content

Expand Down Expand Up @@ -89,16 +88,15 @@ public struct PremiumBlockOverlay: ViewModifier {
}

public extension View {

func premiumContent(_ title: String, subtitle: String?, closeAction: (() -> Void)? = nil) -> some View {
modifier(PremiumBlockOverlay(title: title, subtitle: subtitle, closeAction: closeAction))
}

@available(*, deprecated, renamed: "premiumContent", message: "Renamed")
func premiumContent(title: String, subtitle: String?, closeAction: (() -> Void)? = nil) -> some View {
modifier(PremiumBlockOverlay(title: title, subtitle: subtitle, closeAction: closeAction))
}

func premiumContent(isShow: Binding<Bool> = .constant(true), title: String, subtitle: String?, closeAction: (() -> Void)? = nil) -> some View {
modifier(PremiumBlockOverlay(isShow: isShow, title: title, subtitle: subtitle, closeAction: closeAction))
}
Expand Down
10 changes: 10 additions & 0 deletions Sources/OversizeKit/SystemKit/ErrorView/ErrorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,16 @@ public struct ErrorView: View {
} else {
return nil
}
case let .healthKit(type: type):
if type == .notAccess {
return .accent(L10n.Button.goToSettings, action: {
#if os(iOS)
UIApplication.shared.open(URL(string: UIApplication.openSettingsURLString)!)
#endif
})
} else {
return nil
}
case let .contacts(type: type):
if type == .notAccess {
return .accent(L10n.Button.goToSettings, action: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public struct MapCoordinateView: View {
})
.background(.thickMaterial, ignoresSafeAreaEdges: .top)
}
#if os(iOS)
#if os(iOS)
.toolbar(.hidden, for: .tabBar)
#endif
#endif
} else {
mapView
.safeAreaInset(edge: .top) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/OversizeNotificationKit/LocalNotificationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public struct LocalNotificationView: View {
}
}
}
.surfaceContentRowInsets()
.surfaceContentRowMargins()
if isPendingNotification {
SectionView {
VStack(spacing: .zero) {
Expand All @@ -92,7 +92,7 @@ public struct LocalNotificationView: View {
}
}
}
.surfaceContentRowInsets()
.surfaceContentRowMargins()
}
}
}
Expand Down

0 comments on commit 430af61

Please sign in to comment.