Skip to content

Commit

Permalink
some improvement to the general app
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed Apr 17, 2024
1 parent 6759c12 commit 39ddf2b
Show file tree
Hide file tree
Showing 13 changed files with 90 additions and 25 deletions.
8 changes: 6 additions & 2 deletions AnimeGen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
138661252B8136DC0062AC91 /* nekosapi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138661242B8136DC0062AC91 /* nekosapi.swift */; };
13877B192B82001800251A60 /* SettingsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13877B182B82001800251A60 /* SettingsPage.swift */; };
13877B1E2B82024A00251A60 /* AboutPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13877B1D2B82024A00251A60 /* AboutPage.swift */; };
138A42142BD02D24008B03F4 /* popup-Banner.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138A42132BD02D24008B03F4 /* popup-Banner.swift */; };
13910EBE2B80D380009BF17E /* ImageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EBD2B80D380009BF17E /* ImageExtensions.swift */; };
13910EC02B80D396009BF17E /* UIExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EBF2B80D396009BF17E /* UIExtensions.swift */; };
13910EC52B80D5A6009BF17E /* pic-re.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EC42B80D5A6009BF17E /* pic-re.swift */; };
Expand Down Expand Up @@ -61,6 +62,7 @@
138661242B8136DC0062AC91 /* nekosapi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nekosapi.swift; sourceTree = "<group>"; };
13877B182B82001800251A60 /* SettingsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPage.swift; sourceTree = "<group>"; };
13877B1D2B82024A00251A60 /* AboutPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutPage.swift; sourceTree = "<group>"; };
138A42132BD02D24008B03F4 /* popup-Banner.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "popup-Banner.swift"; sourceTree = "<group>"; };
13910EBD2B80D380009BF17E /* ImageExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageExtensions.swift; sourceTree = "<group>"; };
13910EBF2B80D396009BF17E /* UIExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIExtensions.swift; sourceTree = "<group>"; };
13910EC42B80D5A6009BF17E /* pic-re.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "pic-re.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -188,6 +190,7 @@
children = (
13910EBD2B80D380009BF17E /* ImageExtensions.swift */,
13910EBF2B80D396009BF17E /* UIExtensions.swift */,
138A42132BD02D24008B03F4 /* popup-Banner.swift */,
);
path = Extensions;
sourceTree = "<group>";
Expand Down Expand Up @@ -278,6 +281,7 @@
13910EC72B80D5B9009BF17E /* waifu-im.swift in Sources */,
13877B192B82001800251A60 /* SettingsPage.swift in Sources */,
13BE98C02B828B8000379AB7 /* nekosmoe.swift in Sources */,
138A42142BD02D24008B03F4 /* popup-Banner.swift in Sources */,
130A80572B78C02E0028985F /* ViewController.swift in Sources */,
130A80532B78C02E0028985F /* AppDelegate.swift in Sources */,
130A80552B78C02E0028985F /* SceneDelegate.swift in Sources */,
Expand Down Expand Up @@ -445,7 +449,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = AnimeGen/AnimeGen.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 20;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand Down Expand Up @@ -480,7 +484,7 @@
CODE_SIGN_ENTITLEMENTS = AnimeGen/AnimeGen.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 18;
CURRENT_PROJECT_VERSION = 20;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion AnimeGen/APIs/kyoko.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromKyoko() {
func loadImageFromKyoko() {
startLoadingIndicator()

let categories: [String]
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/nekos-best.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromNekosBest() {
func loadImageFromNekosBest() {
startLoadingIndicator()

let categories = ["neko", "waifu", "kitsune"]
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/nekosapi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromNekosapi() {
func loadImageFromNekosapi() {
startLoadingIndicator()

var ratings: [String] = ["safe"]
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/nekosmoe.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromNekosMoe() {
func loadImageFromNekosMoe() {
startLoadingIndicator()

let isNSFW = UserDefaults.standard.bool(forKey: "enableExplictiCont")
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/pic-re.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromPicRe() {
func loadImageFromPicRe() {
startLoadingIndicator()

let apiEndpoint = "https://pic.re/image"
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/purr.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromPurr() {
func loadImageFromPurr() {
startLoadingIndicator()

var categories: [String]
Expand Down
2 changes: 1 addition & 1 deletion AnimeGen/APIs/waifu-im.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import UIKit

extension ViewController {

func loadImageAndTagsFromWaifuIm() {
func loadImageFromWaifuIm() {
startLoadingIndicator()

let isNSFW = UserDefaults.standard.bool(forKey: "enableExplictiCont")
Expand Down
31 changes: 23 additions & 8 deletions AnimeGen/Buttons/Refresh-API-Button.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,53 @@ extension ViewController {

switch title {
case "pic.re":
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()
}
}
lastImage = imageView.image
loadImageAndTagsFromPicRe()
loadImageFromPicRe()
case "waifu.im":
lastImage = imageView.image
loadImageAndTagsFromWaifuIm()
loadImageFromWaifuIm()
case "nekos.best":
lastImage = imageView.image
loadImageAndTagsFromNekosBest()
loadImageFromNekosBest()
case "waifu.pics":
lastImage = imageView.image
loadImageFromWaifuPics()
case "Hmtai":
lastImage = imageView.image
startHmtaiLoader()
case "Nekos api":
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()
}
}
lastImage = imageView.image
loadImageAndTagsFromNekosapi()
loadImageFromNekosapi()
case "nekos.moe":
lastImage = imageView.image
loadImageAndTagsFromNekosMoe()
loadImageFromNekosMoe()
case "kyoko":
lastImage = imageView.image
loadImageAndTagsFromKyoko()
loadImageFromKyoko()
case "Purr":
lastImage = imageView.image
loadImageAndTagsFromPurr()
loadImageFromPurr()
default:
break
}
}


@objc func apiButtonTapped() {
let alertController = UIAlertController(title: "Select API", message: nil, preferredStyle: .actionSheet)

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)
}
}

}
1 change: 0 additions & 1 deletion AnimeGen/Settings/SettingsPage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ struct SettingsPage: View {
}

}
.listStyle(GroupedListStyle())
.navigationBarTitle("Settings")
}
.navigationViewStyle(StackNavigationViewStyle())
Expand Down
32 changes: 25 additions & 7 deletions AnimeGen/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,24 +292,42 @@ class ViewController: UIViewController {
return
}
switch title {

case "pic.re":
loadImageAndTagsFromPicRe()
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":
loadImageAndTagsFromWaifuIm()
loadImageFromWaifuIm()
case "nekos.best":
loadImageAndTagsFromNekosBest()
loadImageFromNekosBest()
case "waifu.pics":
loadImageFromWaifuPics()
case "Hmtai":
startHmtaiLoader()
case "Nekos api":
loadImageAndTagsFromNekosapi()
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":
loadImageAndTagsFromNekosMoe()
loadImageFromNekosMoe()
case "kyoko":
loadImageAndTagsFromKyoko()
loadImageFromKyoko()
case "Purr":
loadImageAndTagsFromPurr()
loadImageFromPurr()

default:
break
}
Expand Down

0 comments on commit 39ddf2b

Please sign in to comment.