Skip to content

Commit d46103e

Browse files
authored
Merge pull request #21 from VishwaiOSDev/feat/vishwa/ipad-os-support
feat: added iPadOS support
2 parents 36d284a + 472b23b commit d46103e

File tree

6 files changed

+63
-21
lines changed

6 files changed

+63
-21
lines changed

Loadify.xcodeproj/project.pbxproj

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,7 @@
777777
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
778778
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
779779
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
780-
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
781-
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
780+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
782781
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
783782
LD_RUNPATH_SEARCH_PATHS = (
784783
"$(inherited)",
@@ -787,9 +786,11 @@
787786
MARKETING_VERSION = 1.0;
788787
PRODUCT_BUNDLE_IDENTIFIER = io.VishwaiOSDev.Loadify;
789788
PRODUCT_NAME = "$(TARGET_NAME)";
789+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
790+
SUPPORTS_MACCATALYST = NO;
790791
SWIFT_EMIT_LOC_STRINGS = YES;
791792
SWIFT_VERSION = 5.0;
792-
TARGETED_DEVICE_FAMILY = 1;
793+
TARGETED_DEVICE_FAMILY = "1,2";
793794
};
794795
name = Debug;
795796
};
@@ -810,8 +811,7 @@
810811
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
811812
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
812813
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
813-
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
814-
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
814+
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
815815
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
816816
LD_RUNPATH_SEARCH_PATHS = (
817817
"$(inherited)",
@@ -820,9 +820,11 @@
820820
MARKETING_VERSION = 1.0;
821821
PRODUCT_BUNDLE_IDENTIFIER = io.VishwaiOSDev.Loadify;
822822
PRODUCT_NAME = "$(TARGET_NAME)";
823+
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
824+
SUPPORTS_MACCATALYST = NO;
823825
SWIFT_EMIT_LOC_STRINGS = YES;
824826
SWIFT_VERSION = 5.0;
825-
TARGETED_DEVICE_FAMILY = 1;
827+
TARGETED_DEVICE_FAMILY = "1,2";
826828
};
827829
name = Release;
828830
};

Loadify/Others/LoadifyConstants.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,28 @@
77

88
import SwiftUI
99

10+
typealias Device = Loadify.Device
1011
typealias LoadifyTexts = Loadify.Texts
1112
typealias LoadifyColors = LoadifyKit.ColorKit
1213
typealias LoadifyAssets = LoadifyKit.AssetKit
1314

1415
struct Loadify {
1516

17+
18+
static let maxWidth: CGFloat = switch UIDevice.current.userInterfaceIdiom {
19+
case .phone:
20+
.infinity
21+
case .pad:
22+
500
23+
default:
24+
600
25+
}
26+
27+
struct Device {
28+
static let iPad = UIDevice.current.userInterfaceIdiom == .pad
29+
static let isLandscape: Bool = UIDevice.current.orientation.isLandscape
30+
}
31+
1632
struct Texts {
1733
static let loading = "LOADING"
1834
static let downloading = "DOWNLOADING"

Loadify/Others/Modifiers/CardView.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// CardView.swift
3-
//
3+
//
44
//
55
// Created by Vishweshwaran on 30/10/22.
66
//
@@ -19,6 +19,10 @@ struct CardView: ViewModifier {
1919

2020
func body(content: Content) -> some View {
2121
content
22+
.frame(maxWidth: Loadify.maxWidth)
23+
.if(Device.iPad) {
24+
$0.frame(maxHeight: 650)
25+
}
2226
.background(color)
2327
.cornerRadius(cornerRadius)
2428
}

Loadify/Others/Modifiers/CustomButtonStyle.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ struct CustomButtonStyle: ButtonStyle {
2626
func makeBody(configuration: Configuration) -> some View {
2727
configuration.label
2828
.foregroundColor(isDisabled ? .white.opacity(0.5) : .white)
29-
.frame(maxWidth: .infinity, maxHeight: 56)
29+
.frame(maxWidth: Loadify.maxWidth, maxHeight: 56)
3030
.background(isDisabled ? buttonColor.opacity(0.5) : buttonColor)
3131
.cornerRadius(cornerRadius)
3232
.scaleEffect(configuration.isPressed ? 0.98 : 1.0)

Loadify/View/Components/CustomTextField.swift

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// CustomTextField.swift
3-
//
3+
//
44
//
55
// Created by Vishweshwaran on 30/10/22.
66
//
@@ -21,16 +21,18 @@ struct CustomTextField: View {
2121
var body: some View {
2222
VStack(alignment: .leading) {
2323
ZStack(alignment: .leading) {
24-
if text.isEmpty {
25-
Text("\(placeHolder)")
26-
.font(.inter(.regular(size: 16)))
27-
.foregroundColor(LoadifyColors.greyText)
24+
Group {
25+
if text.isEmpty {
26+
Text("\(placeHolder)")
27+
.font(.inter(.regular(size: 16)))
28+
.foregroundColor(LoadifyColors.greyText)
29+
}
30+
textFieldView
31+
.disableAutocorrection(true)
2832
}
29-
textFieldView
30-
.disableAutocorrection(true)
33+
.padding(.horizontal, 16)
3134
}
32-
.frame(maxWidth: .infinity, maxHeight: 56)
33-
.padding(.horizontal, 16)
35+
.frame(maxWidth: Loadify.maxWidth, maxHeight: 56)
3436
.background(LoadifyColors.textfieldBackground)
3537
.cornerRadius(10)
3638
}

Loadify/View/DownloadView.swift

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ struct DownloadView: View {
3030
}
3131
}
3232
.cardView(color: LoadifyColors.textfieldBackground)
33-
Spacer()
33+
if !Device.iPad {
34+
Spacer()
35+
}
3436
footerView
3537
}
3638
.padding()
@@ -56,6 +58,7 @@ struct DownloadView: View {
5658
}
5759
}
5860

61+
@ViewBuilder
5962
private var thumbnailView: some View {
6063
ZStack(alignment: .bottomTrailing) {
6164
ImageView(urlString: details.thumbnails[details.thumbnails.count - 1].url) {
@@ -65,7 +68,7 @@ struct DownloadView: View {
6568
} onLoading: {
6669
progressView
6770
.frame(minHeight: 188)
68-
}
71+
}.frame(maxWidth: Loadify.maxWidth)
6972
durationView
7073
.offset(x: -5, y: -5)
7174
}
@@ -75,7 +78,7 @@ struct DownloadView: View {
7578
image
7679
.resizable()
7780
.frame(minHeight: 188)
78-
.scaledToFit()
81+
.scaleImageBasedOnDevice()
7982
.clipped()
8083
}
8184

@@ -238,8 +241,23 @@ struct DownloadView: View {
238241
}
239242
}
240243

241-
#Preview("iPhone 15 Pro Max") {
244+
extension View {
245+
246+
@ViewBuilder
247+
func scaleImageBasedOnDevice() -> some View {
248+
if Device.iPad {
249+
self.scaledToFill()
250+
} else {
251+
self.scaledToFit()
252+
}
253+
}
254+
}
255+
256+
#Preview("iPad Pro") {
242257
NavigationView {
243258
DownloadView(details: .previews)
259+
.previewDevice("iPad Pro (12.9-inch) (6th generation)")
260+
.previewInterfaceOrientation(.landscapeRight)
244261
}
262+
.navigationViewStyle(StackNavigationViewStyle())
245263
}

0 commit comments

Comments
 (0)