-
Notifications
You must be signed in to change notification settings - Fork 308
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
Sources/EeveeSpotify/Models/Extensions/UIDevice+Extension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import UIKit | ||
|
||
extension UIDevice { | ||
var isIpad: Bool { | ||
self.userInterfaceIdiom == .pad | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import Foundation | ||
|
||
struct GitHubReleaseInfo: Decodable { | ||
var tag_name: String | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/EeveeSpotify/Settings/ViewModifiers/ListRowSeparatorHidden.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import SwiftUI | ||
|
||
struct ListRowSeparatorHidden: ViewModifier { | ||
func body(content: Content) -> some View { | ||
if #available(iOS 15.0, *) { | ||
content | ||
.listRowSeparator(.hidden) | ||
} | ||
else { | ||
content | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
Sources/EeveeSpotify/Settings/Views/EeveeSettingsView+VersionSection.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import SwiftUI | ||
|
||
extension EeveeSettingsView { | ||
|
||
func loadVersion() async throws { | ||
|
||
let (data, _) = try await URLSession.shared.data( | ||
from: URL(string: "https://api.github.com/repos/whoeevee/EeveeSpotify/releases/latest")! | ||
) | ||
|
||
let tag = try JSONDecoder().decode(GitHubReleaseInfo.self, from: data).tag_name | ||
latestVersion = String(tag.dropFirst(5)) | ||
} | ||
|
||
private var isUpdateAvailable: Bool { | ||
guard | ||
let latest = Double(latestVersion), | ||
let current = Double(EeveeSpotify.version) | ||
else { | ||
return false | ||
} | ||
|
||
return latest > current | ||
} | ||
|
||
@ViewBuilder func VersionSection() -> some View { | ||
|
||
Section { | ||
if isUpdateAvailable { | ||
Link( | ||
"Update Available", | ||
destination: URL(string: "https://github.com/whoeevee/EeveeSpotify/releases")! | ||
) | ||
} | ||
} footer: { | ||
VStack(alignment: .leading) { | ||
Text("v\(EeveeSpotify.version)") | ||
|
||
if latestVersion.isEmpty { | ||
HStack(spacing: 10) { | ||
ProgressView() | ||
Text("Checking for Update...") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters