diff --git a/Sources/WishKit/Configuration+Localization.swift b/Sources/WishKit/Configuration+Localization.swift index b485296..9214b61 100644 --- a/Sources/WishKit/Configuration+Localization.swift +++ b/Sources/WishKit/Configuration+Localization.swift @@ -88,6 +88,10 @@ extension Configuration { public var addButtonInNavigationBar: String + public var refresh: String + + public var refreshing: String + public init( requested: String = Localization.default().requested, pending: String = Localization.default().pending, @@ -127,7 +131,9 @@ extension Configuration { emailOptional: String = Localization.default().emailOptional, emailRequired: String = Localization.default().emailRequired, discardEnteredInformation: String = Localization.default().discardEnteredInformation, - addButtonInNavigationBar: String = Localization.default().addButtonInNavigationBar + addButtonInNavigationBar: String = Localization.default().addButtonInNavigationBar, + refresh: String = Localization.default().refresh, + refreshing: String = Localization.default().refreshing ) { self.requested = requested self.pending = pending @@ -168,6 +174,8 @@ extension Configuration { self.emailRequired = emailRequired self.discardEnteredInformation = discardEnteredInformation self.addButtonInNavigationBar = addButtonInNavigationBar + self.refresh = refresh + self.refreshing = refreshing } public static func `default`() -> Localization { @@ -210,7 +218,9 @@ extension Configuration { emailOptional: "Email (optional)", emailRequired: "Email (required)", discardEnteredInformation: "Discard entered information?", - addButtonInNavigationBar: "Create" + addButtonInNavigationBar: "Create", + refresh: "Refresh", + refreshing: "Refreshing.." ) } } diff --git a/Sources/WishKit/ProjectSettings.swift b/Sources/WishKit/ProjectSettings.swift index 0528b0b..2acbb78 100644 --- a/Sources/WishKit/ProjectSettings.swift +++ b/Sources/WishKit/ProjectSettings.swift @@ -13,5 +13,5 @@ struct ProjectSettings { let wishKitUrl = ProcessInfo.processInfo.environment["wishkit-url"] return wishKitUrl ?? "https://www.wishkit.io/api" } - static let sdkVersion = "4.4.0" + static let sdkVersion = "4.5.0" } diff --git a/Sources/WishKit/SwiftUI/WishlistView.swift b/Sources/WishKit/SwiftUI/WishlistView.swift index 631378f..6509ad3 100644 --- a/Sources/WishKit/SwiftUI/WishlistView.swift +++ b/Sources/WishKit/SwiftUI/WishlistView.swift @@ -92,16 +92,18 @@ struct WishlistView: View { Spacer() HStack { Spacer() - AddButton(buttonAction: createWishAction) - .padding([.bottom, .trailing], 20) - .sheet(isPresented: $showingCreateSheet) { - CreateWishView( - createActionCompletion: { wishModel.fetchList() }, - closeAction: { self.showingCreateSheet = false } - ) - .frame(minWidth: 500, idealWidth: 500, minHeight: 400, maxHeight: 600) - .background(backgroundColor) - } + if WishKit.config.buttons.addButton.location == .floating { + AddButton(buttonAction: createWishAction) + .padding([.bottom, .trailing], 20) + .sheet(isPresented: $showingCreateSheet) { + CreateWishView( + createActionCompletion: { wishModel.fetchList() }, + closeAction: { self.showingCreateSheet = false } + ) + .frame(minWidth: 500, idealWidth: 500, minHeight: 400, maxHeight: 600) + .background(backgroundColor) + } + } } } } diff --git a/Sources/WishKit/SwiftUI/macOS/WishlistContainer+macOS.swift b/Sources/WishKit/SwiftUI/macOS/WishlistContainer+macOS.swift index a99f3d2..3209b2d 100644 --- a/Sources/WishKit/SwiftUI/macOS/WishlistContainer+macOS.swift +++ b/Sources/WishKit/SwiftUI/macOS/WishlistContainer+macOS.swift @@ -20,6 +20,9 @@ struct WishlistContainer: View { @State private var isRefreshing = false + + @State + private var showingCreateSheet = false @ObservedObject private var wishModel: WishModel @@ -54,41 +57,63 @@ struct WishlistContainer: View { } var segmentedControlView: some View { - ZStack { + HStack { SegmentedView(selectedWishState: $listType) - .padding() + .padding(.leading, 5) .frame(maxWidth: 300) - HStack { - Button(action: refreshList) { - if isRefreshing { - ProgressView() - .scaleEffect(0.4) - .progressViewStyle(CircularProgressViewStyle()) - } else { - Image(systemName: "arrow.clockwise") - } + Spacer() + + Button(action: refreshList) { + if isRefreshing { + Text(WishKit.config.localization.refreshing) + } else { + Text(WishKit.config.localization.refresh) } - .buttonStyle(PlainButtonStyle()) - .frame(width: 20, height: 20) - .padding(EdgeInsets(top: 0, leading: 315, bottom: 0, trailing: 0)) } - } + + if WishKit.config.buttons.addButton.location == .navigationBar { + Button(action: { self.showingCreateSheet.toggle() }) { + Text(WishKit.config.localization.addButtonInNavigationBar) + } + .padding(.leading, 15) + .sheet(isPresented: $showingCreateSheet) { + CreateWishView( + createActionCompletion: { wishModel.fetchList() }, + closeAction: { self.showingCreateSheet = false } + ) + .frame(minWidth: 500, idealWidth: 500, minHeight: 400, maxHeight: 600) + .background(systemBackgroundColor) + } + } + }.padding(EdgeInsets(top: 15, leading: 5, bottom: 15, trailing: 15)) } var noSegmentedControlView: some View { - Button(action: refreshList) { - if isRefreshing { - ProgressView() - .scaleEffect(0.4) - .progressViewStyle(CircularProgressViewStyle()) - } else { - Image(systemName: "arrow.clockwise") + HStack { + Button(action: refreshList) { + if isRefreshing { + Text(WishKit.config.localization.refreshing) + } else { + Text(WishKit.config.localization.refresh) + } + }.padding(.trailing, WishKit.config.buttons.addButton.location == .floating ? 15 : 0) + + if WishKit.config.buttons.addButton.location == .navigationBar { + Button(action: { self.showingCreateSheet.toggle() }) { + Text(WishKit.config.localization.addButtonInNavigationBar) + } + .padding(.leading, 15) + .sheet(isPresented: $showingCreateSheet) { + CreateWishView( + createActionCompletion: { wishModel.fetchList() }, + closeAction: { self.showingCreateSheet = false } + ) + .frame(minWidth: 500, idealWidth: 500, minHeight: 400, maxHeight: 600) + .background(systemBackgroundColor) + } } - } - .buttonStyle(PlainButtonStyle()) - .frame(width: 20, height: 20) - .padding(EdgeInsets(top: 15, leading: 0, bottom: 15, trailing: 0)) + }.padding(EdgeInsets(top: 15, leading: 5, bottom: 15, trailing: 15)) } var systemBackgroundColor: Color { @@ -105,6 +130,12 @@ struct WishlistContainer: View { } return PrivateTheme.systemBackgroundColor.dark + @unknown default: + if let color = WishKit.theme.tertiaryColor { + return color.light + } + + return PrivateTheme.systemBackgroundColor.light } } }