diff --git a/Backpack-Common.podspec b/Backpack-Common.podspec index 4689b1ade..0db58c5e7 100644 --- a/Backpack-Common.podspec +++ b/Backpack-Common.podspec @@ -34,7 +34,7 @@ Pod::Spec.new do |s| s.ios.resource_bundle = { 'Icons' => 'Backpack-Common/Icons/Assets/*' } - s.ios.deployment_target = '15.1' + s.ios.deployment_target = '16.0' s.source_files = 'Backpack-Common/**/*.swift' s.exclude_files = 'Backpack-Common/Tests/**/*.swift' s.requires_arc = true diff --git a/Backpack-Fonts/Backpack-Fonts.podspec b/Backpack-Fonts/Backpack-Fonts.podspec index ba8c50559..88a499381 100644 --- a/Backpack-Fonts/Backpack-Fonts.podspec +++ b/Backpack-Fonts/Backpack-Fonts.podspec @@ -28,7 +28,7 @@ Pod::Spec.new do |spec| spec.author = { 'Backpack Design System' => 'backpack@skyscanner.net' } - spec.ios.deployment_target = '15.1' + spec.ios.deployment_target = '16.0' spec.source = { git: 'https://github.com/Skyscanner/backpack-ios.git', tag: spec.version.to_s } diff --git a/Backpack-SwiftUI.podspec b/Backpack-SwiftUI.podspec index c28a6364f..8b67b1739 100644 --- a/Backpack-SwiftUI.podspec +++ b/Backpack-SwiftUI.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.source = { git: 'https://github.com/Skyscanner/backpack-ios.git', tag: s.version.to_s } - s.ios.deployment_target = '15.1' + s.ios.deployment_target = '16.0' s.source_files = 'Backpack-SwiftUI/*/Classes/**/*.swift' s.dependency 'Backpack-Common' diff --git a/Backpack-SwiftUI/BottomSheet/Classes/BPKBottomSheet.swift b/Backpack-SwiftUI/BottomSheet/Classes/BPKBottomSheet.swift index 9de695479..393ee1aad 100644 --- a/Backpack-SwiftUI/BottomSheet/Classes/BPKBottomSheet.swift +++ b/Backpack-SwiftUI/BottomSheet/Classes/BPKBottomSheet.swift @@ -41,47 +41,25 @@ public extension View { closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, - presentingController: UIViewController, @ViewBuilder bottomSheetContent: @escaping () -> BottomSheetContent ) -> some View { - if #available(iOS 16.0, *) { - modifier( - BottomSheetContainerViewModifier( - isPresented: isPresented, - contentMode: contentMode, - header: { - header( - closeAction: closeAction( - closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, - closeAction: { isPresented.wrappedValue.toggle() } - ), - title: title, - action: action - ) - }, - bottomSheetContent: bottomSheetContent - ) + modifier( + BottomSheetContainerViewModifier( + isPresented: isPresented, + contentMode: contentMode, + header: { + header( + closeAction: closeAction( + closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, + closeAction: { isPresented.wrappedValue.toggle() } + ), + title: title, + action: action + ) + }, + bottomSheetContent: bottomSheetContent ) - } else { - modifier( - LegacyBottomSheetContainerViewModifier( - isPresented: isPresented, - contentMode: contentMode, - header: { - header( - closeAction: closeAction( - closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, - closeAction: { isPresented.wrappedValue.toggle() } - ), - title: title, - action: action - ) - }, - bottomSheetContent: bottomSheetContent, - presentingController: presentingController - ) - ) - } + ) } @ViewBuilder @@ -91,54 +69,25 @@ public extension View { closeButtonAccessibilityLabel: String? = nil, title: String? = nil, action: BPKBottomSheetAction? = nil, - presentingController: UIViewController, @ViewBuilder bottomSheetContent: @escaping (Item) -> BottomSheetContent ) -> some View { - if #available(iOS 16.0, *) { - modifier( - ItemBottomSheetContainerViewModifier( - item: item, - contentMode: contentMode, - header: { - header( - closeAction: closeAction( - closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, - closeAction: { item.wrappedValue = nil } - ), - title: title, - action: action - ) - }, - bottomSheetContent: bottomSheetContent - ) + modifier( + ItemBottomSheetContainerViewModifier( + item: item, + contentMode: contentMode, + header: { + header( + closeAction: closeAction( + closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, + closeAction: { item.wrappedValue = nil } + ), + title: title, + action: action + ) + }, + bottomSheetContent: bottomSheetContent ) - } else { - modifier( - LegacyBottomSheetContainerViewModifier( - isPresented: Binding( - get: { item.wrappedValue != nil }, - set: { _ in item.wrappedValue = nil } - ), - contentMode: contentMode, - header: { - header( - closeAction: closeAction( - closeButtonAccessibilityLabel: closeButtonAccessibilityLabel, - closeAction: { item.wrappedValue = nil } - ), - title: title, - action: action - ) - }, - bottomSheetContent: { - if let itemValue = item.wrappedValue { - bottomSheetContent(itemValue) - } - }, - presentingController: presentingController - ) - ) - } + ) } private func closeAction( @@ -174,8 +123,7 @@ struct BPKBottomSheet_Previews: PreviewProvider { contentMode: .fitContent, closeButtonAccessibilityLabel: "asd", title: "Hello", action: BPKBottomSheetAction( title: "Action", - action: {}), - presentingController: UIViewController()) { + action: {})) { BPKText("Bottom sheet content") } } diff --git a/Backpack-SwiftUI/BottomSheet/Classes/BottomSheetContainerViewModifier.swift b/Backpack-SwiftUI/BottomSheet/Classes/BottomSheetContainerViewModifier.swift index 1044817e0..5fa4509f6 100644 --- a/Backpack-SwiftUI/BottomSheet/Classes/BottomSheetContainerViewModifier.swift +++ b/Backpack-SwiftUI/BottomSheet/Classes/BottomSheetContainerViewModifier.swift @@ -18,7 +18,6 @@ import SwiftUI -@available(iOS 16.0, *) struct BottomSheetContainerViewModifier: ViewModifier { @Binding var isPresented: Bool @ViewBuilder let header: () -> Header @@ -68,7 +67,6 @@ struct BottomSheetContainerViewModifier: } } -@available(iOS 16.0, *) extension PresentationDetent { static func initialDetent(for contentMode: BPKBottomSheetContentMode) -> PresentationDetent { switch contentMode { diff --git a/Backpack-SwiftUI/BottomSheet/Classes/ContentFitBottomSheet.swift b/Backpack-SwiftUI/BottomSheet/Classes/ContentFitBottomSheet.swift index 4428c0279..87e447742 100644 --- a/Backpack-SwiftUI/BottomSheet/Classes/ContentFitBottomSheet.swift +++ b/Backpack-SwiftUI/BottomSheet/Classes/ContentFitBottomSheet.swift @@ -18,7 +18,6 @@ import SwiftUI -@available(iOS 16.0, *) struct ContentFitBottomSheet: View { let header: () -> Header let bottomSheetContent: () -> Content diff --git a/Backpack-SwiftUI/BottomSheet/Classes/ItemBottomSheetContainerViewModifier.swift b/Backpack-SwiftUI/BottomSheet/Classes/ItemBottomSheetContainerViewModifier.swift index 5170acc1f..f2c4bc080 100644 --- a/Backpack-SwiftUI/BottomSheet/Classes/ItemBottomSheetContainerViewModifier.swift +++ b/Backpack-SwiftUI/BottomSheet/Classes/ItemBottomSheetContainerViewModifier.swift @@ -18,7 +18,6 @@ import SwiftUI -@available(iOS 16.0, *) struct ItemBottomSheetContainerViewModifier< Header: View, BottomSheetContent: View, diff --git a/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContainerViewModifier.swift b/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContainerViewModifier.swift deleted file mode 100644 index b66e8129c..000000000 --- a/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContainerViewModifier.swift +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2018 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import SwiftUI - -struct LegacyBottomSheetContainerViewModifier: ViewModifier { - @Binding var isPresented: Bool - - @State private var controller: UIViewController? - - let contentMode: BPKBottomSheetContentMode - @ViewBuilder let header: () -> Header - let bottomSheetContent: () -> BottomSheetContent - let presentingController: UIViewController - - init( - isPresented: Binding, - contentMode: BPKBottomSheetContentMode, - @ViewBuilder header: @escaping () -> Header, - @ViewBuilder bottomSheetContent: @escaping () -> BottomSheetContent, - presentingController: UIViewController - ) { - self._isPresented = isPresented - self.contentMode = contentMode - self.header = header - self.bottomSheetContent = bottomSheetContent - self.presentingController = presentingController - } - - func body(content: Content) -> some View { - content - .onChange(of: isPresented) { _ in - if isPresented { - showDialogWithContent { - ZStack { - scrim - switch contentMode { - case .large: - GeometryReader { proxy in - contentWithMode(.large(maxHeight: maxHeight(forProxy: proxy))) - } - case .medium: - GeometryReader { proxy in - let maxHeight = maxHeight(forProxy: proxy) - contentWithMode(.medium(minHeight: maxHeight / 2, maxHeight: maxHeight)) - } - case .fitContent: - GeometryReader { proxy in - let maxHeight = maxHeight(forProxy: proxy) - contentWithMode(.fitContent(offset: maxHeight)) - } - } - } - } - } else { - controller?.dismiss(animated: true) - } - } - } - - @ViewBuilder - private var scrim: some View { - if isPresented { - Color(BPKColor.scrimColor) - .onTapGesture { - isPresented.toggle() - } - .ignoresSafeArea() - } - } - - private func contentWithMode(_ mode: LegacyBottomSheetContentViewContentMode) -> some View { - VStack { - Spacer() - LegacyBottomSheetContentView( - isPresented: $isPresented, - contentMode: mode, - header: header, - bottomSheetContent: bottomSheetContent - ) - } - .ignoresSafeArea(edges: .bottom) - } - - private func maxHeight(forProxy proxy: GeometryProxy) -> CGFloat { - proxy.size.height - proxy.safeAreaInsets.top - proxy.safeAreaInsets.bottom - } - - private func showDialogWithContent(_ content: () -> Content) { - let controller = UIHostingController(rootView: content()) - controller.view.backgroundColor = .clear - controller.modalTransitionStyle = .crossDissolve - controller.modalPresentationStyle = .overFullScreen - - presentingController.present(controller, animated: true) - self.controller = controller - } -} - -struct LegacyBottomSheetContainerViewModifier_Previews: PreviewProvider { - static var previews: some View { - BPKButton("Show bottom sheet", action: {}) - .modifier( - LegacyBottomSheetContainerViewModifier( - isPresented: .constant(true), - contentMode: .fitContent, - header: { - BPKText("Header") - }, - bottomSheetContent: { - VStack { - BPKText("Bottom sheet content", style: .heading2) - BPKText("Bottom sheet content", style: .heading4) - BPKText("Bottom sheet content dfgdfg dfgntasd asdasd sdd asd asd asd adsasda") - .lineLimit(nil) - - BPKButton("Make Payment") {} - .padding() - } - }, - presentingController: UIViewController()) - ) - - } -} diff --git a/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContentView.swift b/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContentView.swift deleted file mode 100644 index 2cb23908c..000000000 --- a/Backpack-SwiftUI/BottomSheet/Classes/Legacy/LegacyBottomSheetContentView.swift +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2018 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import SwiftUI - -enum LegacyBottomSheetContentViewContentMode { - case large(maxHeight: CGFloat) - case medium(minHeight: CGFloat, maxHeight: CGFloat) - case fitContent(offset: CGFloat) - - var minHeight: CGFloat { - switch self { - case .large(let height): - return height - case .medium(let height, _): - return height - case .fitContent: - return 0 - } - } - - var maxHeight: CGFloat { - switch self { - case .large(let height): - return height - case .medium(_, let height): - return height - case .fitContent: - return 0 - } - } - - var offset: CGFloat { - switch self { - case .fitContent(let offset): - return offset - default: - return maxHeight - } - } -} - -struct LegacyBottomSheetContentView: View { - private let snapRatio: CGFloat = 0.5 - - @Binding var isPresented: Bool - @GestureState var translation: CGFloat = 0 - @State var offset: CGFloat - - let contentMode: LegacyBottomSheetContentViewContentMode - - let minHeight: CGFloat - let maxHeight: CGFloat - - let header: () -> Header - let bottomSheetContent: () -> Content - - init( - isPresented: Binding, - contentMode: LegacyBottomSheetContentViewContentMode, - header: @escaping () -> Header, - bottomSheetContent: @escaping () -> Content - ) { - _isPresented = isPresented - - self.contentMode = contentMode - minHeight = contentMode.minHeight - maxHeight = contentMode.maxHeight - offset = contentMode.offset - self.header = header - self.bottomSheetContent = bottomSheetContent - } - - var body: some View { - let currentSize = max(maxHeight - offset - translation, minHeight) - VStack(spacing: BPKSpacing.none) { - ZStack(alignment: .top) { - handle.padding(.top, .md) - header() - } - bottomSheetContent() - .frame(maxWidth: .infinity) - .if(maxHeight > 0, transform: { sheetContent in - sheetContent - .frame(maxHeight: maxHeight) - .frame(minHeight: minHeight) - .frame(height: currentSize) - }) - } - .background(BPKColor.surfaceDefaultColor) - .clipShape(.bottomSheet) - .offset(y: verticalOffset(currentSize: currentSize)) - .animation(.interactiveSpring(), value: isPresented) - .animation(.interactiveSpring(), value: offset) - .animation(.interactiveSpring(), value: translation) - .gesture(dragGesture) - .onChange(of: isPresented, perform: onPresentedChanged) - } - - private func verticalOffset(currentSize: CGFloat) -> CGFloat { - guard isPresented else { - if case let .fitContent(offset) = contentMode { - return offset - } - return maxHeight + minHeight - } - guard currentSize - translation < minHeight else { return 0 } - return translation - } - - private var handle: some View { - Color(BPKColor.lineColor) - .clipShape(Capsule()) - .frame(width: BPKSpacing.xxl, height: BPKSpacing.sm) - } - - private var dragGesture: some Gesture { - DragGesture() - .updating($translation, body: { value, state, _ in - if offset == 0, value.translation.height < 0 { return } - state = value.translation.height - }) - .onEnded({ value in - var snapDistance = maxHeight * snapRatio - if case .medium = contentMode { - if offset != 0 { - snapDistance = minHeight * snapRatio - } - offset = value.translation.height > 0 ? minHeight : 0 - } - - if value.translation.height > snapDistance { - withAnimation { - isPresented = false - } - } - }) - } - - private func onPresentedChanged(_ value: Bool) { - withAnimation { - guard value else { - offset = contentMode.offset - return - } - if case .medium = contentMode { - offset = minHeight - } else { - offset = 0 - } - } - } -} - -struct BottomSheetContentView_Previews: PreviewProvider { - private static var large: some View { - LegacyBottomSheetContentView( - isPresented: .constant(false), - contentMode: .large(maxHeight: 200), - header: { - BPKText("Large") - .padding() - }, - bottomSheetContent: { - VStack { - BPKText("Hi") - Spacer() - BPKText("Hi again") - } - } - ) - } - - private static var medium: some View { - LegacyBottomSheetContentView( - isPresented: .constant(false), - contentMode: .medium(minHeight: 100, maxHeight: 200), - header: { - BPKText("Hello") - .padding() - }, - bottomSheetContent: { - VStack { - BPKText("Hi") - Spacer() - BPKText("Hi again") - } - } - ) - } - - private static var fit: some View { - LegacyBottomSheetContentView( - isPresented: .constant(false), - contentMode: .fitContent(offset: 200), - header: { - BPKText("Fitted") - .padding() - }, - bottomSheetContent: { - VStack { - BPKText("Hi") - BPKText("Hi again") - } - } - ) - } - - static var previews: some View { - ZStack { - large - medium - fit - } - } -} diff --git a/Backpack-SwiftUI/TextArea/Classes/BPKTextArea.swift b/Backpack-SwiftUI/TextArea/Classes/BPKTextArea.swift index 09515a27c..c3987302e 100644 --- a/Backpack-SwiftUI/TextArea/Classes/BPKTextArea.swift +++ b/Backpack-SwiftUI/TextArea/Classes/BPKTextArea.swift @@ -72,14 +72,9 @@ public struct BPKTextArea: View { @ViewBuilder var textEditorContent: some View { - if #available(iOS 16.0, *) { - TextEditor(text: $value) - .font(style: .bodyDefault) - .scrollContentBackground(.hidden) - } else { - TextEditor(text: $value) - .font(style: .bodyDefault) - } + TextEditor(text: $value) + .font(style: .bodyDefault) + .scrollContentBackground(.hidden) } public var body: some View { diff --git a/Backpack.podspec b/Backpack.podspec index 5be8011dc..3d2309447 100644 --- a/Backpack.podspec +++ b/Backpack.podspec @@ -31,7 +31,7 @@ Pod::Spec.new do |s| s.source = { git: 'https://github.com/Skyscanner/backpack-ios.git', tag: s.version.to_s } - s.ios.deployment_target = '15.1' + s.ios.deployment_target = '16.0' s.source_files = 'Backpack/Backpack.h', 'Backpack/Common.h', 'Backpack/*/Classes/**/*.{h,m,swift}' s.exclude_files = 'Backpack/Tests/**' s.public_header_files = 'Backpack/Backpack.h', 'Backpack/*/Classes/**/*.h' diff --git a/Backpack/Backpack.h b/Backpack/Backpack.h index 795537500..5b500d10e 100644 --- a/Backpack/Backpack.h +++ b/Backpack/Backpack.h @@ -32,7 +32,6 @@ #import "Button.h" #import "Calendar.h" #import "Card.h" -#import "DarkMode.h" #import "Dialog.h" #import "FlareView.h" #import "Icon.h" diff --git a/Backpack/Button/Classes/BPKButton.m b/Backpack/Button/Classes/BPKButton.m index 682fee111..a9f3d8a1d 100644 --- a/Backpack/Button/Classes/BPKButton.m +++ b/Backpack/Button/Classes/BPKButton.m @@ -33,7 +33,6 @@ #import #import #import -#import #import #import #import diff --git a/Backpack/Button/Classes/BPKLegacyLinkButton.m b/Backpack/Button/Classes/BPKLegacyLinkButton.m index 12c57dcc7..c3ab2b4b8 100644 --- a/Backpack/Button/Classes/BPKLegacyLinkButton.m +++ b/Backpack/Button/Classes/BPKLegacyLinkButton.m @@ -25,7 +25,6 @@ #import #import -#import #import #import #import @@ -459,12 +458,10 @@ - (void)setLinkContentColor:(UIColor *_Nullable)linkContentColor { // color. - (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitCollection { [super traitCollectionDidChange:previousTraitCollection]; -#if __BPK_DARK_MODE_SUPPORTED if (self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) { [self updateAppearance]; [self updateTitle]; } -#endif } + (CGFloat)buttonTitleIconSpacing { diff --git a/Backpack/Card/Classes/BPKCardDivider.m b/Backpack/Card/Classes/BPKCardDivider.m index afdfb264f..962023fcb 100644 --- a/Backpack/Card/Classes/BPKCardDivider.m +++ b/Backpack/Card/Classes/BPKCardDivider.m @@ -19,7 +19,6 @@ #import "BPKCardDivider.h" #import -#import #import #import #import @@ -94,11 +93,9 @@ - (void)layoutSubviews { // Note this is needed to correctly update the `CGColor` used for the line . - (void)traitCollectionDidChange:(nullable UITraitCollection *)previousTraitCollection { [super traitCollectionDidChange:previousTraitCollection]; -#if __BPK_DARK_MODE_SUPPORTED if (self.traitCollection.userInterfaceStyle != previousTraitCollection.userInterfaceStyle) { [self updateLineColor]; } -#endif } @end diff --git a/Backpack/Color/Classes/Generated/BPKColor.m b/Backpack/Color/Classes/Generated/BPKColor.m index ca3b599b9..b3615c4a1 100644 --- a/Backpack/Color/Classes/Generated/BPKColor.m +++ b/Backpack/Color/Classes/Generated/BPKColor.m @@ -18,8 +18,6 @@ */ #import "BPKColor.h" -#import - @interface BPKColor() @property(nonatomic, strong, readonly) NSCache *dynamicColorsCache; @end @@ -555,28 +553,23 @@ + (NSString *)cacheKeyForColor:(UIColor *)color { } + (UIColor *)dynamicColorWithLightVariant:(UIColor *)lightVariant darkVariant:(UIColor *)darkVariant { -#if __BPK_DARK_MODE_SUPPORTED - if (@available(iOS 13.0, *)) { - NSString *cacheKey = [NSString stringWithFormat:@"%@_%@", [self cacheKeyForColor:lightVariant], [self cacheKeyForColor:darkVariant]]; - UIColor *potentialCacheHit = [[self dynamicColorsCache] objectForKey:cacheKey]; - - if (potentialCacheHit) { - return potentialCacheHit; - } - - UIColor *newDynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) { - if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { - return darkVariant; - } else { - return lightVariant; - } - }]; - - [[self dynamicColorsCache] setObject:newDynamicColor forKey:cacheKey]; - return newDynamicColor; + NSString *cacheKey = [NSString stringWithFormat:@"%@_%@", [self cacheKeyForColor:lightVariant], [self cacheKeyForColor:darkVariant]]; + UIColor *potentialCacheHit = [[self dynamicColorsCache] objectForKey:cacheKey]; + + if (potentialCacheHit) { + return potentialCacheHit; } -#endif - return lightVariant; + + UIColor *newDynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) { + if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + return darkVariant; + } else { + return lightVariant; + } + }]; + + [[self dynamicColorsCache] setObject:newDynamicColor forKey:cacheKey]; + return newDynamicColor; } @end diff --git a/Backpack/DarkMode/Classes/DarkMode.h b/Backpack/DarkMode/Classes/DarkMode.h deleted file mode 100644 index e4cc11e54..000000000 --- a/Backpack/DarkMode/Classes/DarkMode.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Backpack - Skyscanner's Design System - * - * Copyright 2018 Skyscanner Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __BACKPACK_DARKMODE__ -#define __BACKPACK_DARKMODE__ - -#define __BPK_DARK_MODE_SUPPORTED __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 - -#endif diff --git a/Backpack/DarkMode/README.md b/Backpack/DarkMode/README.md deleted file mode 100644 index ce198c9ee..000000000 --- a/Backpack/DarkMode/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Backpack/DarkMode - -## Usage - -`Backpack/DarkMode`/`BPKDarkMode` contains utilities that help when developing applications which support dark mode. - -`__DARK_MODE_SUPPORTED` is a macro which determines if dark-mode specific compiler features are available. For example, `UIViewController` `overrideUserInterfaceStyle` property, which is only available in XCode 11. - -### Objective-C - -**`__DARK_MODE_SUPPORTED`** - -```objective-c -#import - -#if __BPK_DARK_MODE_SUPPORTED - self.overrideUserInterfaceStyle = UIUserInterfaceStyleLight; -#endif -``` - -### Swift - -**`__DARK_MODE_SUPPORTED`** - -```swift -import BPKDarkMode - -#if __BPK_DARK_MODE_SUPPORTED - overrideUserInterfaceStyle = .light -#endif -``` - diff --git a/Backpack/NavigationBar/Classes/BPKNavigationBar.m b/Backpack/NavigationBar/Classes/BPKNavigationBar.m index 33de264a8..7aed821c7 100644 --- a/Backpack/NavigationBar/Classes/BPKNavigationBar.m +++ b/Backpack/NavigationBar/Classes/BPKNavigationBar.m @@ -19,7 +19,6 @@ #import #import -#import #import #import diff --git a/Example/Backpack Screenshot/SnapshotHelper.swift b/Example/Backpack Screenshot/SnapshotHelper.swift index 6dec13020..765988ef3 100644 --- a/Example/Backpack Screenshot/SnapshotHelper.swift +++ b/Example/Backpack Screenshot/SnapshotHelper.swift @@ -199,15 +199,11 @@ open class Snapshot: NSObject { #if os(watchOS) return image #else - if #available(iOS 10.0, *) { - let format = UIGraphicsImageRendererFormat() - format.scale = image.scale - let renderer = UIGraphicsImageRenderer(size: image.size, format: format) - return renderer.image { context in - image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) - } - } else { - return image + let format = UIGraphicsImageRendererFormat() + format.scale = image.scale + let renderer = UIGraphicsImageRenderer(size: image.size, format: format) + return renderer.image { context in + image.draw(in: CGRect(x: 0, y: 0, width: image.size.width, height: image.size.height)) } #endif } diff --git a/Example/Backpack.xcodeproj/project.pbxproj b/Example/Backpack.xcodeproj/project.pbxproj index 3f10ea5e1..1cc446bf2 100644 --- a/Example/Backpack.xcodeproj/project.pbxproj +++ b/Example/Backpack.xcodeproj/project.pbxproj @@ -2060,7 +2060,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -2108,7 +2108,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; SWIFT_SWIFT3_OBJC_INFERENCE = Default; @@ -2137,7 +2137,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = NO; INFOPLIST_FILE = "Backpack/Backpack-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.0; MODULE_NAME = ExampleApp; @@ -2171,7 +2171,7 @@ GCC_WARN_UNUSED_LABEL = YES; GCC_WARN_UNUSED_PARAMETER = NO; INFOPLIST_FILE = "Backpack/Backpack-Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; MARKETING_VERSION = 1.0; MODULE_NAME = ExampleApp; @@ -2197,7 +2197,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Backpack Screenshot/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -2226,7 +2226,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Backpack Screenshot/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; @@ -2257,7 +2257,7 @@ DEBUG_INFORMATION_FORMAT = dwarf; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Backpack NativeUITests/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; @@ -2291,7 +2291,7 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu11; INFOPLIST_FILE = "Backpack NativeUITests/Info.plist"; - IPHONEOS_DEPLOYMENT_TARGET = 15.1; + IPHONEOS_DEPLOYMENT_TARGET = 16.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MTL_ENABLE_DEBUG_INFO = NO; MTL_FAST_MATH = YES; diff --git a/Example/Backpack/SwiftUI/Components/BottomSheet/BottomSheetExampleView.swift b/Example/Backpack/SwiftUI/Components/BottomSheet/BottomSheetExampleView.swift index 7fea0cc0b..3c0055e44 100644 --- a/Example/Backpack/SwiftUI/Components/BottomSheet/BottomSheetExampleView.swift +++ b/Example/Backpack/SwiftUI/Components/BottomSheet/BottomSheetExampleView.swift @@ -57,7 +57,7 @@ struct BottomSheetExampleView: View { BPKButton("Show content with item") { itemToShow = .init(id: "1", name: "Fight to London") } - .bpkBottomSheet(item: $itemToShow, presentingController: rootViewController) { item in + .bpkBottomSheet(item: $itemToShow) { item in content(item.name) } } @@ -70,7 +70,6 @@ struct BottomSheetExampleView: View { title: "Action", action: { closableBottomSheetShown.toggle() } ), - presentingController: rootViewController, bottomSheetContent: { content() } ) .bpkBottomSheet( @@ -81,7 +80,6 @@ struct BottomSheetExampleView: View { title: "Action", action: { largeBottomSheetShown.toggle() } ), - presentingController: rootViewController, bottomSheetContent: { content() } ) .bpkBottomSheet( @@ -92,7 +90,6 @@ struct BottomSheetExampleView: View { title: "Action", action: { mediumBottomSheetShown.toggle() } ), - presentingController: rootViewController, bottomSheetContent: { content() } ) .bpkBottomSheet( @@ -103,7 +100,6 @@ struct BottomSheetExampleView: View { title: "Action", action: { fitContentBottomSheetShown.toggle() } ), - presentingController: rootViewController, bottomSheetContent: { VStack { BPKText("Bottom sheet content") diff --git a/Example/Backpack/UIKit/Components/Button/BPKButtonsViewController.m b/Example/Backpack/UIKit/Components/Button/BPKButtonsViewController.m index 75a51deac..e724b3eb0 100644 --- a/Example/Backpack/UIKit/Components/Button/BPKButtonsViewController.m +++ b/Example/Backpack/UIKit/Components/Button/BPKButtonsViewController.m @@ -20,7 +20,6 @@ #import "Backpack_Native-Swift.h" #import -#import #import #import diff --git a/Example/Backpack/Utils/ThemeHelpers.swift b/Example/Backpack/Utils/ThemeHelpers.swift index 10b7863af..6a69e77db 100644 --- a/Example/Backpack/Utils/ThemeHelpers.swift +++ b/Example/Backpack/Utils/ThemeHelpers.swift @@ -17,7 +17,6 @@ */ import Foundation -import Backpack.DarkMode import Backpack.Theme class ThemeHelpers: NSObject { diff --git a/Example/Podfile b/Example/Podfile index 5bf9307a7..6f411068d 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,6 +1,6 @@ source 'https://cdn.cocoapods.org/' -platform :ios, '15.1' +platform :ios, '16.0' use_frameworks! ensure_bundler! '> 2.0' @@ -25,7 +25,7 @@ post_install do |installer| puts 'Removing static analyzer support' installer.pods_project.targets.each do |target| target.build_configurations.each do |config| - config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '15.1' + config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0' end if target.name == "FSCalendar" diff --git a/Example/Podfile.lock b/Example/Podfile.lock index ab905791e..d25489bb3 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -81,10 +81,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: AppCenter: 87ef6eefd8ade4df59e88951288587429f3dd2a5 - Backpack: 6ea2b8690a1ac4e10a1bc19c84e9106acdfe2c02 - Backpack-Common: 9a47d236de2f7fea7366f7a893423b8375ee7a39 - Backpack-Fonts: 8d10ac600d738cb7ae6e49fee969800c2db51f6b - Backpack-SwiftUI: f1d0e98dc0beb0f0a44178796aae6c407fb9d7d3 + Backpack: d92da3a71c1615e7a449b252565fbb9da2555dc2 + Backpack-Common: e8993f9fa4e7a79236ea16a4a06b5f73f3517d53 + Backpack-Fonts: 2ed96553a5325156a154d788defbdc6306dae5ef + Backpack-SwiftUI: 7f36a28a756c20c27e6a095eb7a37c87f8432dac FloatingPanel: 3cee815e9ded75b632543fa73ab655a1ef941452 FSCalendar: 2d1d0d9398f12d439f55c1fe0f01525b151b8260 MBProgressHUD: 3ee5efcc380f6a79a7cc9b363dd669c5e1ae7406 @@ -93,6 +93,6 @@ SPEC CHECKSUMS: SwiftLint: 99f82d07b837b942dd563c668de129a03fc3fb52 TTTAttributedLabel: 8cffe8e127e4e82ff3af1e5386d4cd0ad000b656 -PODFILE CHECKSUM: db90d722d21004d77a9d6cf29da110b644239024 +PODFILE CHECKSUM: bc2882487d825902b2d9100e60d4f94c3d1239a8 COCOAPODS: 1.15.2 diff --git a/templates/BPKColor.m.njk b/templates/BPKColor.m.njk index ed8299c7d..2763fd2bc 100644 --- a/templates/BPKColor.m.njk +++ b/templates/BPKColor.m.njk @@ -18,8 +18,6 @@ */ #import "BPKColor.h" -#import - @interface BPKColor() @property(nonatomic, strong, readonly) NSCache *dynamicColorsCache; @end @@ -75,28 +73,23 @@ } + (UIColor *)dynamicColorWithLightVariant:(UIColor *)lightVariant darkVariant:(UIColor *)darkVariant { -#if __BPK_DARK_MODE_SUPPORTED - if (@available(iOS 13.0, *)) { - NSString *cacheKey = [NSString stringWithFormat:@"%@_%@", [self cacheKeyForColor:lightVariant], [self cacheKeyForColor:darkVariant]]; - UIColor *potentialCacheHit = [[self dynamicColorsCache] objectForKey:cacheKey]; + NSString *cacheKey = [NSString stringWithFormat:@"%@_%@", [self cacheKeyForColor:lightVariant], [self cacheKeyForColor:darkVariant]]; + UIColor *potentialCacheHit = [[self dynamicColorsCache] objectForKey:cacheKey]; - if (potentialCacheHit) { - return potentialCacheHit; - } + if (potentialCacheHit) { + return potentialCacheHit; + } - UIColor *newDynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) { - if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { - return darkVariant; - } else { - return lightVariant; - } - }]; + UIColor *newDynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * _Nonnull traitCollection) { + if (traitCollection.userInterfaceStyle == UIUserInterfaceStyleDark) { + return darkVariant; + } else { + return lightVariant; + } + }]; - [[self dynamicColorsCache] setObject:newDynamicColor forKey:cacheKey]; - return newDynamicColor; - } -#endif - return lightVariant; + [[self dynamicColorsCache] setObject:newDynamicColor forKey:cacheKey]; + return newDynamicColor; } @end