Skip to content

Commit

Permalink
updated few files
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush9029 committed Dec 27, 2021
1 parent b5e9a07 commit 3708f2d
Show file tree
Hide file tree
Showing 15 changed files with 2,109 additions and 174 deletions.
16 changes: 10 additions & 6 deletions NativeTwitch.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
objects = {

/* Begin PBXBuildFile section */
C24D9C5C2779457B005B3380 /* StreamsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C24D9C5B2779457B005B3380 /* StreamsView.swift */; };
C269946E2647088900B3DCF7 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = C269946D2647088900B3DCF7 /* Alamofire */; };
C269947126470C1400B3DCF7 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = C269947026470C1400B3DCF7 /* SwiftyJSON */; };
C269947D2647251D00B3DCF7 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C269947C2647251D00B3DCF7 /* SettingsView.swift */; };
Expand All @@ -33,6 +34,7 @@
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
C24D9C5B2779457B005B3380 /* StreamsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamsView.swift; sourceTree = "<group>"; };
C269947C2647251D00B3DCF7 /* SettingsView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = "<group>"; };
C26994802647255000B3DCF7 /* StreamRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StreamRowView.swift; sourceTree = "<group>"; };
C26FBE54264679F1006818AB /* TwitchDataViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TwitchDataViewModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -105,10 +107,10 @@
children = (
C2A7BCEF26462B030038CFB5 /* NativeTwitchApp.swift */,
C2A7BCF126462B030038CFB5 /* ContentView.swift */,
C2E360D5272A3F43005C6858 /* Extensions */,
C2A7BD1C26462B320038CFB5 /* View */,
C2948E1726E424F0001EABC0 /* View Model */,
C2A7BD1B26462B2C0038CFB5 /* Model */,
C2948E1726E424F0001EABC0 /* View Model */,
C2E360D5272A3F43005C6858 /* Extensions */,
C2A7BCF326462B050038CFB5 /* Assets.xcassets */,
C2A7BCF826462B050038CFB5 /* Info.plist */,
C2A7BCF926462B050038CFB5 /* NativeTwitch.entitlements */,
Expand Down Expand Up @@ -148,6 +150,7 @@
C2A7BD1C26462B320038CFB5 /* View */ = {
isa = PBXGroup;
children = (
C24D9C5B2779457B005B3380 /* StreamsView.swift */,
C2E360E7272A5A9A005C6858 /* SubViews */,
C2E360E4272A5508005C6858 /* UpdateView */,
C269947C2647251D00B3DCF7 /* SettingsView.swift */,
Expand Down Expand Up @@ -282,6 +285,7 @@
C2948E1926E424FC001EABC0 /* Stream.swift in Sources */,
C2E360DD272A451A005C6858 /* AutoUpdater.swift in Sources */,
C2948E1B26E4250A001EABC0 /* User.swift in Sources */,
C24D9C5C2779457B005B3380 /* StreamsView.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -412,7 +416,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_ASSET_PATHS = "\"NativeTwitch/Preview Content\"";
DEVELOPMENT_TEAM = 4538W4A79B;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -423,7 +427,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.aayush.opensource.NativeTwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -439,7 +443,7 @@
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 7;
CURRENT_PROJECT_VERSION = 8;
DEVELOPMENT_ASSET_PATHS = "\"NativeTwitch/Preview Content\"";
DEVELOPMENT_TEAM = 4538W4A79B;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -450,7 +454,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.2;
MARKETING_VERSION = 1.5;
PRODUCT_BUNDLE_IDENTIFIER = com.aayush.opensource.NativeTwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down
Binary file not shown.
66 changes: 3 additions & 63 deletions NativeTwitch/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,11 @@ import Foundation
import SwiftUI

struct ContentView: View {

@AppStorage(AppStorageStrings.clientID.rawValue) var twitchClientID = ""
@AppStorage(AppStorageStrings.oauthToken.rawValue) var oauthToken = ""
@AppStorage(AppStorageStrings.streamlinkLocation.rawValue) var streamlinkLocation = ""

@EnvironmentObject var twitchData: TwitchDataViewModel

@Environment(\.openURL) var openURL


var body: some View {
Group{
switch twitchData.status{
default:
Text("")
}
if twitchData.status != .streamLoaded{
Text("Loading Streams")
.font(.title)
Expand All @@ -37,58 +27,8 @@ struct ContentView: View {
.foregroundColor(.gray.opacity(0.5))
}
else{
VStack {
ScrollView(.vertical, showsIndicators: false){
ForEach(twitchData.streams, id: \.self) { stream in
StreamRowView(stream: stream, const: Constants(twitchClientID: twitchClientID, oauthToken: oauthToken, streamlinkLocation: streamlinkLocation))
.environmentObject(twitchData)
.onTapGesture(count: 2, perform: {
twitchData.watchStream(streamLinkLocation: streamlinkLocation, streamerUsername: stream.user_name)
})
.contextMenu(ContextMenu(menuItems: {
VStack {
Button("Play \(twitchData.iinaEnabled ? "using iina" : "")"){
twitchData.watchStream(streamLinkLocation: streamlinkLocation, streamerUsername: stream.user_name)
}
Button("Low latency using VLC"){
twitchData.watchLowLatencyWithVLC(streamLinkLocation: streamlinkLocation, streamUsername: stream.user_name)
}
Button("Open chat in Native Chat"){

openURL(URL(string: "nativechat://\(stream.user_name)")!) { accepted in
DispatchQueue.main.sync {
twitchData.isShowingNativeChatAlert = !accepted
}
}
}

Divider()

Button("Open twitch.tv/\(stream.user_name)"){
NSWorkspace.shared.open(stream.getStreamURL())
}

Button("Open chat in Safari"){
NSWorkspace.shared.open(stream.getChatURL())
}

}

}))
}.padding(.bottom)
}
}

.alert(Text("Native Chat isn't installed"), isPresented: $twitchData.isShowingNativeChatAlert) {
HStack{
Button("What's Native chat?"){
openURL(URL(string: "https://github.com/Aayush9029/NativeChat")!)
}
Button("Don't care, Didn't ask"){
print("OK")
}
}
}
StreamsView()
.environmentObject(twitchData)
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion NativeTwitch/Extensions/Double+Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import Foundation

extension Double {
var shortStringRepresentation: String {
if self.isZero {
return "0"
}
if self.isNaN {
return "NaN"
}
Expand All @@ -26,7 +29,8 @@ extension Double {
interval /= 1000.0
}
// + 2 to have one digit after the comma, + 1 to not have any.
// Remove the * and the number of digits argument to display all the digits after the comma.
// Remove the * and the number of digits argument to display all the digits after the comma.\

return "\(String(format: "%0.*g", Int(log10(abs(interval))) + 2, interval))\(units[i])"
}
}
2 changes: 1 addition & 1 deletion NativeTwitch/Model/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ enum AppStorageStrings: String{
case oauthToken = "oauthToken"
case streamlinkLocation = "streamlinkLocation"
case showingInfo = "showingInfo"
case iinaLocation = "IINA location (optional)"
case iinaEnabled = "Enable IINA"
case experimental = "Experimental Features"
case tmpDirectory = "Temporary Updates Download Directory"
case remoteUpdateJson = "URL Remote Version"
}
4 changes: 2 additions & 2 deletions NativeTwitch/NativeTwitchApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ struct NativeTwitchApp: App {
.background(VisualEffectView(material: NSVisualEffectView.Material.hudWindow, blendingMode: NSVisualEffectView.BlendingMode.behindWindow))
.openNewWindow(with: "New Update Available")
}
twitchData.addToLogs(response: updater.status.rawValue, hidestatus: true)
twitchData.addToLogs(updater.status.rawValue, hidestatus: true)
})
.alert(Text("Restart app to finish update"), isPresented: $updater.showingRestartAlert) {
HStack{
Expand Down Expand Up @@ -72,7 +72,7 @@ struct NativeTwitchApp: App {
SettingsView(showingLogs: $showingLogs)
.environmentObject(twitchData)
.background(VisualEffectView(material: NSVisualEffectView.Material.sidebar, blendingMode: NSVisualEffectView.BlendingMode.behindWindow))
.frame(width: 320, height: showingLogs ? 650: 400)
.frame(width: 320, height: showingLogs ? 720: 460)
.fixedSize()
}

Expand Down
Loading

0 comments on commit 3708f2d

Please sign in to comment.