Skip to content

Commit

Permalink
Frost view, image cache, thumbnail view
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush9029 committed Apr 25, 2022
1 parent 93f03a5 commit 151ae27
Show file tree
Hide file tree
Showing 11 changed files with 241 additions and 112 deletions.
29 changes: 23 additions & 6 deletions NativeTwitch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
B23F5E992814BCCC00A8DD89 /* GeneralPreferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B23F5E982814BCCC00A8DD89 /* GeneralPreferenceView.swift */; };
B23F5E9B2814BCD500A8DD89 /* PreferencesView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B23F5E9A2814BCD500A8DD89 /* PreferencesView.swift */; };
B23F5E9D2814BD8400A8DD89 /* LogsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B23F5E9C2814BD8400A8DD89 /* LogsView.swift */; };
B2960446281626E500F0E491 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = B2960445281626E500F0E491 /* SDWebImageSwiftUI */; };
C2188F4127B75BA900868039 /* LiveBadgeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C2188F4027B75BA900868039 /* LiveBadgeView.swift */; };
C24D9C5C2779457B005B3380 /* StreamsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24D9C5B2779457B005B3380 /* StreamsView.swift */; };
C269946E2647088900B3DCF7 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = C269946D2647088900B3DCF7 /* Alamofire */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
B2960446281626E500F0E491 /* SDWebImageSwiftUI in Frameworks */,
C2E4CEA0272B068900EAC8BB /* Zip in Frameworks */,
C269947126470C1400B3DCF7 /* SwiftyJSON in Frameworks */,
C269946E2647088900B3DCF7 /* Alamofire in Frameworks */,
Expand Down Expand Up @@ -169,10 +171,10 @@
C2A7BD1C26462B320038CFB5 /* View */ = {
isa = PBXGroup;
children = (
C2E360E4272A5508005C6858 /* UpdateView */,
C2E360E7272A5A9A005C6858 /* SubViews */,
B23F5E952814BC0700A8DD89 /* PreferencesView */,
C24D9C5B2779457B005B3380 /* StreamsView.swift */,
C2E360E7272A5A9A005C6858 /* SubViews */,
C2E360E4272A5508005C6858 /* UpdateView */,
C26994802647255000B3DCF7 /* StreamRowView.swift */,
);
path = View;
Expand Down Expand Up @@ -228,6 +230,7 @@
C269946D2647088900B3DCF7 /* Alamofire */,
C269947026470C1400B3DCF7 /* SwiftyJSON */,
C2E4CE9F272B068900EAC8BB /* Zip */,
B2960445281626E500F0E491 /* SDWebImageSwiftUI */,
);
productName = NativeTwitch;
productReference = C2A7BCEC26462B030038CFB5 /* NativeTwitch.app */;
Expand Down Expand Up @@ -260,6 +263,7 @@
C269946C2647088900B3DCF7 /* XCRemoteSwiftPackageReference "Alamofire" */,
C269946F26470C1400B3DCF7 /* XCRemoteSwiftPackageReference "SwiftyJSON" */,
C2E4CE9E272B068900EAC8BB /* XCRemoteSwiftPackageReference "Zip" */,
B2960444281626E500F0E491 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */,
);
productRefGroup = C2A7BCED26462B030038CFB5 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -440,7 +444,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_ASSET_PATHS = "\"NativeTwitch/Preview Content\"";
DEVELOPMENT_TEAM = 4538W4A79B;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -451,7 +455,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.7;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.aayush.opensource.NativeTwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -467,7 +471,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 11;
DEVELOPMENT_ASSET_PATHS = "\"NativeTwitch/Preview Content\"";
DEVELOPMENT_TEAM = 4538W4A79B;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -478,7 +482,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.7;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.aayush.opensource.NativeTwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -509,6 +513,14 @@
/* End XCConfigurationList section */

/* Begin XCRemoteSwiftPackageReference section */
B2960444281626E500F0E491 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SDWebImage/SDWebImageSwiftUI.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.0.0;
};
};
C269946C2647088900B3DCF7 /* XCRemoteSwiftPackageReference "Alamofire" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Alamofire/Alamofire.git";
Expand Down Expand Up @@ -536,6 +548,11 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
B2960445281626E500F0E491 /* SDWebImageSwiftUI */ = {
isa = XCSwiftPackageProductDependency;
package = B2960444281626E500F0E491 /* XCRemoteSwiftPackageReference "SDWebImageSwiftUI" */;
productName = SDWebImageSwiftUI;
};
C269946D2647088900B3DCF7 /* Alamofire */ = {
isa = XCSwiftPackageProductDependency;
package = C269946C2647088900B3DCF7 /* XCRemoteSwiftPackageReference "Alamofire" */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,50 @@
{
"object": {
"pins": [
{
"package": "Alamofire",
"repositoryURL": "https://github.com/Alamofire/Alamofire.git",
"state": {
"branch": null,
"revision": "f96b619bcb2383b43d898402283924b80e2c4bae",
"version": "5.4.3"
}
},
{
"package": "SwiftyJSON",
"repositoryURL": "https://github.com/SwiftyJSON/SwiftyJSON.git",
"state": {
"branch": null,
"revision": "b3dcd7dbd0d488e1a7077cb33b00f2083e382f07",
"version": "5.0.1"
}
},
{
"package": "Zip",
"repositoryURL": "https://github.com/marmelroy/Zip.git",
"state": {
"branch": null,
"revision": "bd19d974e8a38cc8d3a88c90c8a107386c3b8ccf",
"version": "2.1.1"
}
"pins" : [
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "f96b619bcb2383b43d898402283924b80e2c4bae",
"version" : "5.4.3"
}
]
},
"version": 1
},
{
"identity" : "sdwebimage",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImage.git",
"state" : {
"revision" : "2e63d0061da449ad0ed130768d05dceb1496de44",
"version" : "5.12.5"
}
},
{
"identity" : "sdwebimageswiftui",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SDWebImage/SDWebImageSwiftUI.git",
"state" : {
"revision" : "cd8625b7cf11a97698e180d28bb7d5d357196678",
"version" : "2.0.2"
}
},
{
"identity" : "swiftyjson",
"kind" : "remoteSourceControl",
"location" : "https://github.com/SwiftyJSON/SwiftyJSON.git",
"state" : {
"revision" : "b3dcd7dbd0d488e1a7077cb33b00f2083e382f07",
"version" : "5.0.1"
}
},
{
"identity" : "zip",
"kind" : "remoteSourceControl",
"location" : "https://github.com/marmelroy/Zip.git",
"state" : {
"revision" : "bd19d974e8a38cc8d3a88c90c8a107386c3b8ccf",
"version" : "2.1.1"
}
}
],
"version" : 2
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,22 @@
uuid = "D0407C19-EC43-4BC5-835A-CA28D6062F05"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "F5B47E6A-B8F5-4355-B3CF-E644C6E1E45F"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "NativeTwitch/View/StreamRowView.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "99"
endingLineNumber = "99"
landmarkName = "getUserLogo()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,63 @@
<key>NativeTwitch.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
<key>Playground (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
<key>Playground (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
<integer>4</integer>
</dict>
<key>Playground (Playground) 3.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Playground (Playground) 4.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>5</integer>
</dict>
<key>Playground (Playground) 5.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>6</integer>
</dict>
<key>Playground (Playground) 6.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>7</integer>
</dict>
<key>Playground (Playground) 7.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>8</integer>
</dict>
<key>Playground (Playground) 8.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>9</integer>
</dict>
<key>Playground (Playground).xcscheme</key>
<dict>
Expand Down
25 changes: 21 additions & 4 deletions NativeTwitch/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,38 @@ struct ContentView: View {

var body: some View {
Group {
HStack {
Spacer()
}
if twitchData.status != .streamLoaded {
Text("Loading Streams")
.font(.title)
.bold()
.foregroundColor(.gray.opacity(0.5))
VStack {
Spacer()
ProgressView()
.opacity(0.75)
.padding(.bottom)

Text("Loading Streams")
.font(.title)
.bold()
.foregroundColor(.gray.opacity(0.5))
}

}
if twitchData.status == .streamLoaded && twitchData.streams.count == 0 {
VStack {
Spacer()
Text("All streams are offline :(")
.font(.title)
.bold()
.foregroundColor(.gray.opacity(0.5))
Spacer()
}
} else {
StreamsView()
.environmentObject(twitchData)
}
}
.padding(.top, 24)
.background(VisualEffectView(material: .hudWindow, blendingMode: .behindWindow)).ignoresSafeArea()
}
}
6 changes: 0 additions & 6 deletions NativeTwitch/Model/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import Foundation

// MARK: - Constants
struct Constants {
let twitchClientID: String
let oauthToken: String

let streamlinkLocation: String
let streamlinkConfig: String

static let downloadDir = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first!
static let installDir = FileManager.default.urls(for: .applicationDirectory, in: .localDomainMask).first!

Expand Down
8 changes: 7 additions & 1 deletion NativeTwitch/Model/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct Stream: Hashable {
var title: String
var user_logo: String?
var user_login: String // using this instead of username (fixes Chinise character issue)
var thumbnail_url: String

func getStreamURL() -> URL {
if let url = URL(string: "https://www.twitch.tv/\(user_login)") {
Expand All @@ -31,6 +32,10 @@ struct Stream: Hashable {
return getStreamURL()
}

func getThumbnail(width: Int = 400, height: Int = 248) -> String {
return thumbnail_url.replacingOccurrences(of: "{width}", with: "\(width)").replacingOccurrences(of: "{height}", with: "\(height)")
}

static let exampleStream = Stream(
user_name: "xQcOW",
user_id: "71092938",
Expand All @@ -39,6 +44,7 @@ struct Stream: Hashable {
game_name: "Grand Theft Auto V",
title: "[Nopixel] RIDEALONG PIERRE PP PAUL RIDS LOS SANTOS OF ALL THE CRIMINAL SCUM",
user_logo: "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png",
user_login: "xqcow"
user_login: "xqcow",
thumbnail_url: "https://static-cdn.jtvnw.net/previews-ttv/live_user_xqcow-400x248.jpg"
)
}
2 changes: 1 addition & 1 deletion NativeTwitch/View Model/TwitchDataViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class TwitchDataViewModel: ObservableObject {
for (_, subJson):(String, JSON) in json["data"] {
let d = subJson

self.streams.append(Stream(user_name: d["user_name"].string!, user_id: d["user_id"].string!, viewer_count: d["viewer_count"].int!, type: d["type"].string!, game_name: d["game_name"].string!, title: d["title"].string!, user_login: d["user_login"].string ?? "Unknown"))
self.streams.append(Stream(user_name: d["user_name"].string!, user_id: d["user_id"].string!, viewer_count: d["viewer_count"].int!, type: d["type"].string!, game_name: d["game_name"].string!, title: d["title"].string!, user_login: d["user_login"].string ?? "Unknown", thumbnail_url: d["thumbnail_url"].string!))

}
self.status = .streamLoaded
Expand Down
Loading

0 comments on commit 151ae27

Please sign in to comment.