Skip to content

Commit

Permalink
ios 13/14 support again 💪
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed Apr 21, 2024
1 parent e9e401d commit 08b1232
Show file tree
Hide file tree
Showing 10 changed files with 160 additions and 44 deletions.
16 changes: 10 additions & 6 deletions AnimeGen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
131515712BAB284A00A1C770 /* Refresh-API-Button.swift in Sources */ = {isa = PBXBuildFile; fileRef = 131515702BAB284A00A1C770 /* Refresh-API-Button.swift */; };
131515742BAB28C900A1C770 /* SDWebImage in Frameworks */ = {isa = PBXBuildFile; productRef = 131515732BAB28C900A1C770 /* SDWebImage */; };
134C3A862BD404C5001C3C22 /* Main-onboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = 134C3A852BD404C5001C3C22 /* Main-onboard.swift */; };
135DA6512BD501FD0083235B /* popup-Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 135DA6502BD501FD0083235B /* popup-Banner.swift */; };
1365E8202BB0112D005E0548 /* HistoryView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1365E81F2BB0112D005E0548 /* HistoryView.swift */; };
1365E8222BB011F6005E0548 /* ImageHistory.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1365E8212BB011F6005E0548 /* ImageHistory.swift */; };
1365E8242BB01236005E0548 /* History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1365E8232BB01236005E0548 /* History.swift */; };
Expand Down Expand Up @@ -57,6 +58,7 @@
1315156E2BAB27D600A1C770 /* Web-Share.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Web-Share.swift"; sourceTree = "<group>"; };
131515702BAB284A00A1C770 /* Refresh-API-Button.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Refresh-API-Button.swift"; sourceTree = "<group>"; };
134C3A852BD404C5001C3C22 /* Main-onboard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Main-onboard.swift"; sourceTree = "<group>"; };
135DA6502BD501FD0083235B /* popup-Banner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "popup-Banner.swift"; sourceTree = "<group>"; };
1365E81F2BB0112D005E0548 /* HistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HistoryView.swift; sourceTree = "<group>"; };
1365E8212BB011F6005E0548 /* ImageHistory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageHistory.swift; sourceTree = "<group>"; };
1365E8232BB01236005E0548 /* History.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = History.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -202,6 +204,7 @@
children = (
13910EBD2B80D380009BF17E /* ImageExtensions.swift */,
13910EBF2B80D396009BF17E /* UIExtensions.swift */,
135DA6502BD501FD0083235B /* popup-Banner.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -306,6 +309,7 @@
131515712BAB284A00A1C770 /* Refresh-API-Button.swift in Sources */,
1365E8242BB01236005E0548 /* History.swift in Sources */,
13C8011F2B94CAD900BFD198 /* HmtaiReader.swift in Sources */,
135DA6512BD501FD0083235B /* popup-Banner.swift in Sources */,
13910EC02B80D396009BF17E /* UIExtensions.swift in Sources */,
138661252B8136DC0062AC91 /* nekosapi.swift in Sources */,
13910EC92B80D5C2009BF17E /* nekos-best.swift in Sources */,
Expand Down Expand Up @@ -389,7 +393,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -444,7 +448,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
Expand All @@ -461,7 +465,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = AnimeGen/AnimeGen.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand All @@ -473,7 +477,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand All @@ -496,7 +500,7 @@
CODE_SIGN_ENTITLEMENTS = AnimeGen/AnimeGen.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 26;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand All @@ -508,7 +512,7 @@
INFOPLIST_KEY_UISupportedInterfaceOrientations = UIInterfaceOrientationPortrait;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = UIInterfaceOrientationPortrait;
IPHONEOS_DEPLOYMENT_TARGET = 15.0;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
Expand Down
Binary file not shown.
50 changes: 34 additions & 16 deletions AnimeGen/Boarding/Main-onboard.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,38 @@ struct TutorialView: View {
@Environment(\.presentationMode) var presentationMode
@State private var currentStep = 0
@State private var isShowingBlur = false

let steps: [TutorialStep] = [
TutorialStep(text: "Welcom to AnimeGen.", icon: "star.fill", tintColor: .accentColor, position: "A simple way to enjoy anime Art"),
TutorialStep(text: "Tap the Top button to switch image providers. There are 9 API options with unique images.", icon: "bookmark.fill", tintColor: .yellow, position: "Placed on the Top Center"),
TutorialStep(text: "Hit refresh for a new image.", icon: "arrow.clockwise.circle.fill", tintColor: .teal, position: "Placed on the Bottom Center"),
TutorialStep(text: "Show some love! Tap the heart to save an image.", icon: "heart.fill", tintColor: .red, position: "Placed on the Bottom Center Right"),
TutorialStep(text: "Rewind to the last image with the rewind icon.", icon: "arrowshape.turn.up.backward.circle.fill", tintColor: .green, position: "Placed on the Bottom Center Left"),
TutorialStep(text: "Share the current image with the share icon.", icon: "square.and.arrow.up.circle.fill", tintColor: .purple, position: "Placed on the Bottom Right Corner"),
TutorialStep(text: "Access the image URL with the Safari icon.", icon: "safari.fill", tintColor: .blue, position: "Placed on the Bottom Left Corner"),
TutorialStep(text: "Gear up! Tap the gear icon to tweak settings.", icon: "gearshape", tintColor: .gray, position: "Placed on the Top Left Corner"),
TutorialStep(text: "Check out the session history with the clock icon in the top right.", icon: "clock.arrow.circlepath", tintColor: .pink, position: "Placed on the Top Right Corner"),
TutorialStep(text: "AnimeGen care about your privacy. Nothing is stored!", icon: "shield.fill", tintColor: .orange, position: "Visit Settings → About, to learn more."),
TutorialStep(text: "Enjoy your Stay!", icon: "photo.on.rectangle.angled", tintColor: .indigo, position: "Don't forget to share your feedbacks!")
]

var steps: [TutorialStep] {
if #available(iOS 15.0, *) {
return [
TutorialStep(text: "Welcom to AnimeGen", icon: "star.fill", tintColor: .accentColor, position: "A simple way to enjoy anime Art"),
TutorialStep(text: "Tap the Top button to switch image providers. There are 9 API options with unique images.", icon: "bookmark.fill", tintColor: .yellow, position: "Placed on the Top Center"),
TutorialStep(text: "Hit refresh for a new image.", icon: "arrow.clockwise.circle.fill", tintColor: .secondary, position: "Placed on the Bottom Center"),
TutorialStep(text: "Show some love! Tap the heart to save an image.", icon: "heart.fill", tintColor: .red, position: "Placed on the Bottom Center Right"),
TutorialStep(text: "Rewind to the last image with the rewind icon.", icon: "arrowshape.turn.up.backward.circle.fill", tintColor: .green, position: "Placed on the Bottom Center Left"),
TutorialStep(text: "Share the current image with the share icon.", icon: "square.and.arrow.up.circle.fill", tintColor: .purple, position: "Placed on the Bottom Right Corner"),
TutorialStep(text: "Access the image URL with the Safari icon.", icon: "safari.fill", tintColor: .blue, position: "Placed on the Bottom Left Corner"),
TutorialStep(text: "Gear up! Tap the gear icon to tweak settings.", icon: "gearshape", tintColor: .gray, position: "Placed on the Top Left Corner"),
TutorialStep(text: "Check out the session history with the clock icon in the top right.", icon: "clock.arrow.circlepath", tintColor: .pink, position: "Placed on the Top Right Corner"),
TutorialStep(text: "AnimeGen care about your privacy. Nothing is stored!", icon: "shield.fill", tintColor: .orange, position: "Visit Settings → About, to learn more."),
TutorialStep(text: "Enjoy your Stay!", icon: "photo.on.rectangle.angled", tintColor: .accentColor, position: "Don't forget to share your feedbacks!")
]
} else {
return [
TutorialStep(text: "Welcom to AnimeGen", icon: "star.fill", tintColor: .accentColor, position: "A simple way to enjoy anime Art"),
TutorialStep(text: "Tap the Top button to switch image providers. There are 9 API options with unique images.", icon: "bookmark.fill", tintColor: .yellow, position: "Placed on the Top Center"),
TutorialStep(text: "Hit refresh for a new image.", icon: "arrow.clockwise.circle.fill", tintColor: .secondary, position: "Placed on the Bottom Center"),
TutorialStep(text: "Show some love! Tap the heart to save an image.", icon: "heart.fill", tintColor: .red, position: "Placed on the Bottom Center Right"),
TutorialStep(text: "Rewind to the last image with the rewind icon.", icon: "arrowshape.turn.up.backward.circle.fill", tintColor: .green, position: "Placed on the Bottom Center Left"),
TutorialStep(text: "Share the current image with the share icon.", icon: "square.and.arrow.up.on.square.fill", tintColor: .purple, position: "Placed on the Bottom Right Corner"),
TutorialStep(text: "Access the image URL with the Safari icon.", icon: "safari.fill", tintColor: .blue, position: "Placed on the Bottom Left Corner"),
TutorialStep(text: "Gear up! Tap the gear icon to tweak settings.", icon: "gearshape", tintColor: .gray, position: "Placed on the Top Left Corner"),
TutorialStep(text: "Check out the session history with the clock icon in the top right.", icon: "clock.arrow.circlepath", tintColor: .pink, position: "Placed on the Top Right Corner"),
TutorialStep(text: "AnimeGen care about your privacy. Nothing is stored!", icon: "shield.fill", tintColor: .orange, position: "Visit Settings → About, to learn more."),
TutorialStep(text: "Enjoy your Stay!", icon: "photo.on.rectangle.angled", tintColor: .accentColor, position: "Don't forget to share your feedbacks!")
]
}
}

var body: some View {
ZStack {
Expand All @@ -57,14 +75,14 @@ struct TutorialView: View {
}

Text(steps[currentStep].text)
.font(.title2)
.font(.title)
.fontWeight(.semibold)
.multilineTextAlignment(.center)
.padding()
.foregroundColor(.primary)

Text(steps[currentStep].position)
.font(.title3)
.font(.headline)
.multilineTextAlignment(.center)
.padding()
.foregroundColor(.primary)
Expand Down
7 changes: 4 additions & 3 deletions AnimeGen/Buttons/HearthButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ extension ViewController {

if let data = image.imageData,
let source = CGImageSourceCreateWithData(data as CFData, nil),
let utType = CGImageSourceGetType(source) as String?,
UTType(utType)?.conforms(to: .gif) == true {
let utType = CGImageSourceGetType(source),
UTTypeConformsTo(utType, kUTTypeGIF) {

PHPhotoLibrary.shared().performChanges {
let creationRequest = PHAssetCreationRequest.forAsset()
creationRequest.addResource(with: .photo, data: data, options: nil)
Expand Down Expand Up @@ -53,4 +53,5 @@ extension ViewController {
print("Image saved successfully")
}
}

}
16 changes: 16 additions & 0 deletions AnimeGen/Buttons/Refresh-API-Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ extension ViewController {
case "pic.re":
lastImage = imageView.image
loadImageFromPicRe()
showPopUpBanner(message: "This API is not supported on your iOS version!", viewController: self) {
if #available(iOS 14.0, *) {
// nothing here cuz ios 14+ 💪
} else {
self.apiButton.setTitle("waifu.im", for: .normal)
self.loadImageFromWaifuIm()
}
}
case "waifu.im":
lastImage = imageView.image
loadImageFromWaifuIm()
Expand All @@ -33,6 +41,14 @@ extension ViewController {
case "Nekos api":
lastImage = imageView.image
loadImageFromNekosapi()
showPopUpBanner(message: "This API is not supported on your iOS version!", viewController: self) {
if #available(iOS 14.0, *) {
// nothing here cuz ios 14+ 💪
} else {
self.apiButton.setTitle("waifu.im", for: .normal)
self.loadImageFromWaifuIm()
}
}
case "nekos.moe":
lastImage = imageView.image
loadImageFromNekosMoe()
Expand Down
29 changes: 29 additions & 0 deletions AnimeGen/Extensions/popup-Banner.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// popup-Banner.swift
// AnimeGen
//
// Created by cranci on 17/04/24.
//

import UIKit

extension ViewController {

func showPopUpBanner(message: String, viewController: UIViewController, completion: (() -> Void)?) {
if #available(iOS 14.0, *) {
// nothing here cuz ios 14+ 💪
completion?()
} else {

// ios 13.x 😭

let alertController = UIAlertController(title: nil, message: message, preferredStyle: .alert)
let okAction = UIAlertAction(title: "OK", style: .default) { _ in
completion?()
}
alertController.addAction(okAction)
viewController.present(alertController, animated: true, completion: nil)
}
}

}
10 changes: 8 additions & 2 deletions AnimeGen/History/HistoryView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,19 @@ struct HistoryView: View {

var body: some View {
NavigationView {
ImageGrid(selectedImage: $selectedImage, isSaveAlertPresented: $isSaveAlertPresented)
.navigationBarTitle("History - \(ImageHistory.images.count) images")
if #available(iOS 15.0, *) {
ImageGrid(selectedImage: $selectedImage, isSaveAlertPresented: $isSaveAlertPresented)
.navigationBarTitle("History - \(ImageHistory.images.count) images")
} else {
ImageGridiOS13(selectedImage: $selectedImage, isSaveAlertPresented: $isSaveAlertPresented)
.navigationBarTitle("History - \(ImageHistory.images.count) images")
}
}
.navigationViewStyle(StackNavigationViewStyle())
}
}

@available(iOS 15.0, *)
struct ImageGrid: View {
@Binding var selectedImage: UIImage?
@Binding var isSaveAlertPresented: Bool
Expand Down
28 changes: 20 additions & 8 deletions AnimeGen/Settings/SettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,26 @@ struct SettingsPage: View {
.foregroundColor(.accentColor)
}

Button(action: {
isShowingTutorial = true
}) {
Text("Show Tutorial")
.foregroundColor(.accentColor)
}
.fullScreenCover(isPresented: $isShowingTutorial) {
TutorialView()
if #available(iOS 14.0, *) {
Button(action: {
isShowingTutorial = true
}) {
Text("Show Tutorial")
.foregroundColor(.accentColor)
}
.fullScreenCover(isPresented: $isShowingTutorial) {
TutorialView()
}
} else {
Button(action: {
isShowingTutorial = true
}) {
Text("Show Tutorial")
.foregroundColor(.accentColor)
}
.sheet(isPresented: $isShowingTutorial) {
TutorialView()
}
}
}
}
Expand Down
Loading

0 comments on commit 08b1232

Please sign in to comment.