Skip to content

Commit

Permalink
Merge pull request #21 from VishwaiOSDev/feat/vishwa/ipad-os-support
Browse files Browse the repository at this point in the history
feat: added iPadOS support
  • Loading branch information
VishwaiOSDev authored Oct 12, 2023
2 parents 36d284a + 472b23b commit d46103e
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 21 deletions.
14 changes: 8 additions & 6 deletions Loadify.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -777,8 +777,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -787,9 +786,11 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = io.VishwaiOSDev.Loadify;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
};
Expand All @@ -810,8 +811,7 @@
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchScreen_Generation = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown";
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -820,9 +820,11 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = io.VishwaiOSDev.Loadify;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator";
SUPPORTS_MACCATALYST = NO;
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = 1;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
};
Expand Down
16 changes: 16 additions & 0 deletions Loadify/Others/LoadifyConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,28 @@

import SwiftUI

typealias Device = Loadify.Device
typealias LoadifyTexts = Loadify.Texts
typealias LoadifyColors = LoadifyKit.ColorKit
typealias LoadifyAssets = LoadifyKit.AssetKit

struct Loadify {


static let maxWidth: CGFloat = switch UIDevice.current.userInterfaceIdiom {
case .phone:
.infinity
case .pad:
500
default:
600
}

struct Device {
static let iPad = UIDevice.current.userInterfaceIdiom == .pad
static let isLandscape: Bool = UIDevice.current.orientation.isLandscape
}

struct Texts {
static let loading = "LOADING"
static let downloading = "DOWNLOADING"
Expand Down
6 changes: 5 additions & 1 deletion Loadify/Others/Modifiers/CardView.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CardView.swift
//
//
//
// Created by Vishweshwaran on 30/10/22.
//
Expand All @@ -19,6 +19,10 @@ struct CardView: ViewModifier {

func body(content: Content) -> some View {
content
.frame(maxWidth: Loadify.maxWidth)
.if(Device.iPad) {
$0.frame(maxHeight: 650)
}
.background(color)
.cornerRadius(cornerRadius)
}
Expand Down
2 changes: 1 addition & 1 deletion Loadify/Others/Modifiers/CustomButtonStyle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ struct CustomButtonStyle: ButtonStyle {
func makeBody(configuration: Configuration) -> some View {
configuration.label
.foregroundColor(isDisabled ? .white.opacity(0.5) : .white)
.frame(maxWidth: .infinity, maxHeight: 56)
.frame(maxWidth: Loadify.maxWidth, maxHeight: 56)
.background(isDisabled ? buttonColor.opacity(0.5) : buttonColor)
.cornerRadius(cornerRadius)
.scaleEffect(configuration.isPressed ? 0.98 : 1.0)
Expand Down
20 changes: 11 additions & 9 deletions Loadify/View/Components/CustomTextField.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// CustomTextField.swift
//
//
//
// Created by Vishweshwaran on 30/10/22.
//
Expand All @@ -21,16 +21,18 @@ struct CustomTextField: View {
var body: some View {
VStack(alignment: .leading) {
ZStack(alignment: .leading) {
if text.isEmpty {
Text("\(placeHolder)")
.font(.inter(.regular(size: 16)))
.foregroundColor(LoadifyColors.greyText)
Group {
if text.isEmpty {
Text("\(placeHolder)")
.font(.inter(.regular(size: 16)))
.foregroundColor(LoadifyColors.greyText)
}
textFieldView
.disableAutocorrection(true)
}
textFieldView
.disableAutocorrection(true)
.padding(.horizontal, 16)
}
.frame(maxWidth: .infinity, maxHeight: 56)
.padding(.horizontal, 16)
.frame(maxWidth: Loadify.maxWidth, maxHeight: 56)
.background(LoadifyColors.textfieldBackground)
.cornerRadius(10)
}
Expand Down
26 changes: 22 additions & 4 deletions Loadify/View/DownloadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ struct DownloadView: View {
}
}
.cardView(color: LoadifyColors.textfieldBackground)
Spacer()
if !Device.iPad {
Spacer()
}
footerView
}
.padding()
Expand All @@ -56,6 +58,7 @@ struct DownloadView: View {
}
}

@ViewBuilder
private var thumbnailView: some View {
ZStack(alignment: .bottomTrailing) {
ImageView(urlString: details.thumbnails[details.thumbnails.count - 1].url) {
Expand All @@ -65,7 +68,7 @@ struct DownloadView: View {
} onLoading: {
progressView
.frame(minHeight: 188)
}
}.frame(maxWidth: Loadify.maxWidth)
durationView
.offset(x: -5, y: -5)
}
Expand All @@ -75,7 +78,7 @@ struct DownloadView: View {
image
.resizable()
.frame(minHeight: 188)
.scaledToFit()
.scaleImageBasedOnDevice()
.clipped()
}

Expand Down Expand Up @@ -238,8 +241,23 @@ struct DownloadView: View {
}
}

#Preview("iPhone 15 Pro Max") {
extension View {

@ViewBuilder
func scaleImageBasedOnDevice() -> some View {
if Device.iPad {
self.scaledToFill()
} else {
self.scaledToFit()
}
}
}

#Preview("iPad Pro") {
NavigationView {
DownloadView(details: .previews)
.previewDevice("iPad Pro (12.9-inch) (6th generation)")
.previewInterfaceOrientation(.landscapeRight)
}
.navigationViewStyle(StackNavigationViewStyle())
}

0 comments on commit d46103e

Please sign in to comment.