Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrated user-listen api #3

Merged
merged 10 commits into from
Jun 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
89 changes: 89 additions & 0 deletions Listenbrainz.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,25 @@
6F842DF629C64EF200DBBC7B /* SpotifyiOS in Frameworks */ = {isa = PBXBuildFile; productRef = 6F842DF529C64EF200DBBC7B /* SpotifyiOS */; };
6F842DF929C6509300DBBC7B /* SpotifyManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F842DF829C6509300DBBC7B /* SpotifyManager.swift */; };
6F842DFB29C650A600DBBC7B /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6F842DFA29C650A600DBBC7B /* Constants.swift */; };
BB05864E2A25034200744FF0 /* SongDetailView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB05864D2A25034200744FF0 /* SongDetailView.swift */; };
BB0586512A2503E600744FF0 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = BB0586502A2503E600744FF0 /* Alamofire */; };
BB0586532A25042C00744FF0 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0586522A25042C00744FF0 /* HomeViewModel.swift */; };
BB0586572A2504AD00744FF0 /* Listens.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0586562A2504AD00744FF0 /* Listens.swift */; };
BB05865A2A25052600744FF0 /* HomeRepository.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB0586592A25052600744FF0 /* HomeRepository.swift */; };
BB05865C2A25053600744FF0 /* HomeRepositoryImpl.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB05865B2A25053600744FF0 /* HomeRepositoryImpl.swift */; };
BB2A4F5329EB48BE006933BC /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A4F5229EB48BE006933BC /* ContentView.swift */; };
BB2A4F5529EB48CC006933BC /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A4F5429EB48CC006933BC /* HomeView.swift */; };
BB2A4F5729EB48DF006933BC /* ProfileView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A4F5629EB48DF006933BC /* ProfileView.swift */; };
BB2A4F5929EB48ED006933BC /* PlayerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BB2A4F5829EB48ED006933BC /* PlayerView.swift */; };
BBD28DD12A2F9D9B00AD57C6 /* Album.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DD02A2F9D9B00AD57C6 /* Album.swift */; };
BBD28DD32A2F9DC400AD57C6 /* Artist.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DD22A2F9DC400AD57C6 /* Artist.swift */; };
BBD28DD52A2F9DDC00AD57C6 /* Payload.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DD42A2F9DDC00AD57C6 /* Payload.swift */; };
BBD28DD72A2F9E0A00AD57C6 /* Listen.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DD62A2F9E0A00AD57C6 /* Listen.swift */; };
BBD28DD92A2F9E2E00AD57C6 /* TrackMetadata.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DD82A2F9E2E00AD57C6 /* TrackMetadata.swift */; };
BBD28DDB2A2F9E5400AD57C6 /* AdditionalInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DDA2A2F9E5400AD57C6 /* AdditionalInfo.swift */; };
BBD28DDD2A2F9E8B00AD57C6 /* MbidMapping.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DDC2A2F9E8B00AD57C6 /* MbidMapping.swift */; };
BBD28DDF2A2F9EA300AD57C6 /* ArtistElement.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DDE2A2F9EA300AD57C6 /* ArtistElement.swift */; };
BBD28DE12A2F9EB900AD57C6 /* Track.swift in Sources */ = {isa = PBXBuildFile; fileRef = BBD28DE02A2F9EB900AD57C6 /* Track.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -52,10 +67,24 @@
6F842DF829C6509300DBBC7B /* SpotifyManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SpotifyManager.swift; sourceTree = "<group>"; };
6F842DFA29C650A600DBBC7B /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
6F842DFC29C6516800DBBC7B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BB05864D2A25034200744FF0 /* SongDetailView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SongDetailView.swift; sourceTree = "<group>"; };
BB0586522A25042C00744FF0 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
BB0586562A2504AD00744FF0 /* Listens.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Listens.swift; sourceTree = "<group>"; };
BB0586592A25052600744FF0 /* HomeRepository.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeRepository.swift; sourceTree = "<group>"; };
BB05865B2A25053600744FF0 /* HomeRepositoryImpl.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeRepositoryImpl.swift; sourceTree = "<group>"; };
BB2A4F5229EB48BE006933BC /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
BB2A4F5429EB48CC006933BC /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
BB2A4F5629EB48DF006933BC /* ProfileView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ProfileView.swift; sourceTree = "<group>"; };
BB2A4F5829EB48ED006933BC /* PlayerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayerView.swift; sourceTree = "<group>"; };
BBD28DD02A2F9D9B00AD57C6 /* Album.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Album.swift; sourceTree = "<group>"; };
BBD28DD22A2F9DC400AD57C6 /* Artist.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Artist.swift; sourceTree = "<group>"; };
BBD28DD42A2F9DDC00AD57C6 /* Payload.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Payload.swift; sourceTree = "<group>"; };
BBD28DD62A2F9E0A00AD57C6 /* Listen.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Listen.swift; sourceTree = "<group>"; };
BBD28DD82A2F9E2E00AD57C6 /* TrackMetadata.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TrackMetadata.swift; sourceTree = "<group>"; };
BBD28DDA2A2F9E5400AD57C6 /* AdditionalInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AdditionalInfo.swift; sourceTree = "<group>"; };
BBD28DDC2A2F9E8B00AD57C6 /* MbidMapping.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MbidMapping.swift; sourceTree = "<group>"; };
BBD28DDE2A2F9EA300AD57C6 /* ArtistElement.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ArtistElement.swift; sourceTree = "<group>"; };
BBD28DE02A2F9EB900AD57C6 /* Track.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Track.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -64,6 +93,7 @@
buildActionMask = 2147483647;
files = (
6F842DF629C64EF200DBBC7B /* SpotifyiOS in Frameworks */,
BB0586512A2503E600744FF0 /* Alamofire in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -115,6 +145,7 @@
BB2A4F5229EB48BE006933BC /* ContentView.swift */,
BB2A4F5429EB48CC006933BC /* HomeView.swift */,
BB2A4F5629EB48DF006933BC /* ProfileView.swift */,
BB05864D2A25034200744FF0 /* SongDetailView.swift */,
BB2A4F5829EB48ED006933BC /* PlayerView.swift */,
);
path = Screens;
Expand Down Expand Up @@ -145,8 +176,10 @@
children = (
6F7620A129C66C7300CDA3E8 /* UI */,
6F7620A029C66C6600CDA3E8 /* Application */,
BB0586582A2504CC00744FF0 /* repository */,
6F842E0029C6551900DBBC7B /* Resources */,
6F842DFD29C651D400DBBC7B /* ViewModel */,
BB0586552A25049100744FF0 /* model */,
6F842DF729C6508600DBBC7B /* Utils */,
);
path = Listenbrainz;
Expand Down Expand Up @@ -181,6 +214,7 @@
isa = PBXGroup;
children = (
6F842DF829C6509300DBBC7B /* SpotifyManager.swift */,
BB0586522A25042C00744FF0 /* HomeViewModel.swift */,
);
path = ViewModel;
sourceTree = "<group>";
Expand All @@ -194,6 +228,32 @@
path = Resources;
sourceTree = "<group>";
};
BB0586552A25049100744FF0 /* model */ = {
isa = PBXGroup;
children = (
BB0586562A2504AD00744FF0 /* Listens.swift */,
BBD28DD02A2F9D9B00AD57C6 /* Album.swift */,
BBD28DD22A2F9DC400AD57C6 /* Artist.swift */,
BBD28DD42A2F9DDC00AD57C6 /* Payload.swift */,
BBD28DD62A2F9E0A00AD57C6 /* Listen.swift */,
BBD28DD82A2F9E2E00AD57C6 /* TrackMetadata.swift */,
BBD28DDA2A2F9E5400AD57C6 /* AdditionalInfo.swift */,
BBD28DDC2A2F9E8B00AD57C6 /* MbidMapping.swift */,
BBD28DDE2A2F9EA300AD57C6 /* ArtistElement.swift */,
BBD28DE02A2F9EB900AD57C6 /* Track.swift */,
);
path = model;
sourceTree = "<group>";
};
BB0586582A2504CC00744FF0 /* repository */ = {
isa = PBXGroup;
children = (
BB0586592A25052600744FF0 /* HomeRepository.swift */,
BB05865B2A25053600744FF0 /* HomeRepositoryImpl.swift */,
);
path = repository;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
Expand All @@ -212,6 +272,7 @@
name = Listenbrainz;
packageProductDependencies = (
6F842DF529C64EF200DBBC7B /* SpotifyiOS */,
BB0586502A2503E600744FF0 /* Alamofire */,
);
productName = Listenbrainz;
productReference = 6F842DC729C64E3E00DBBC7B /* Listenbrainz.app */;
Expand Down Expand Up @@ -287,6 +348,7 @@
mainGroup = 6F842DBE29C64E3E00DBBC7B;
packageReferences = (
6F842DF429C64EF200DBBC7B /* XCRemoteSwiftPackageReference "ios-sdk" */,
BB05864F2A2503E600744FF0 /* XCRemoteSwiftPackageReference "Alamofire" */,
);
productRefGroup = 6F842DC829C64E3E00DBBC7B /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -329,14 +391,28 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
BBD28DD72A2F9E0A00AD57C6 /* Listen.swift in Sources */,
BBD28DE12A2F9EB900AD57C6 /* Track.swift in Sources */,
6F842DF929C6509300DBBC7B /* SpotifyManager.swift in Sources */,
BB2A4F5329EB48BE006933BC /* ContentView.swift in Sources */,
BBD28DDF2A2F9EA300AD57C6 /* ArtistElement.swift in Sources */,
BBD28DD52A2F9DDC00AD57C6 /* Payload.swift in Sources */,
BBD28DDD2A2F9E8B00AD57C6 /* MbidMapping.swift in Sources */,
BBD28DD92A2F9E2E00AD57C6 /* TrackMetadata.swift in Sources */,
6F842DCD29C64E3E00DBBC7B /* ListensView.swift in Sources */,
BBD28DD32A2F9DC400AD57C6 /* Artist.swift in Sources */,
BB0586532A25042C00744FF0 /* HomeViewModel.swift in Sources */,
BB05865A2A25052600744FF0 /* HomeRepository.swift in Sources */,
BBD28DD12A2F9D9B00AD57C6 /* Album.swift in Sources */,
BB2A4F5929EB48ED006933BC /* PlayerView.swift in Sources */,
BB05864E2A25034200744FF0 /* SongDetailView.swift in Sources */,
BB2A4F5529EB48CC006933BC /* HomeView.swift in Sources */,
6F842DCB29C64E3E00DBBC7B /* ListenbrainzApp.swift in Sources */,
BB0586572A2504AD00744FF0 /* Listens.swift in Sources */,
BB2A4F5729EB48DF006933BC /* ProfileView.swift in Sources */,
BBD28DDB2A2F9E5400AD57C6 /* AdditionalInfo.swift in Sources */,
6F842DFB29C650A600DBBC7B /* Constants.swift in Sources */,
BB05865C2A25053600744FF0 /* HomeRepositoryImpl.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -675,6 +751,14 @@
kind = branch;
};
};
BB05864F2A2503E600744FF0 /* XCRemoteSwiftPackageReference "Alamofire" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Alamofire/Alamofire.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -683,6 +767,11 @@
package = 6F842DF429C64EF200DBBC7B /* XCRemoteSwiftPackageReference "ios-sdk" */;
productName = SpotifyiOS;
};
BB0586502A2503E600744FF0 /* Alamofire */ = {
isa = XCSwiftPackageProductDependency;
package = BB05864F2A2503E600744FF0 /* XCRemoteSwiftPackageReference "Alamofire" */;
productName = Alamofire;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 6F842DBF29C64E3E00DBBC7B /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"pins" : [
{
"identity" : "alamofire",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Alamofire/Alamofire.git",
"state" : {
"revision" : "bc268c28fb170f494de9e9927c371b8342979ece",
"version" : "5.7.1"
}
},
{
"identity" : "ios-sdk",
"kind" : "remoteSourceControl",
Expand Down
30 changes: 15 additions & 15 deletions Listenbrainz/Resources/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>org.listenbrainz.ios</string>
<key>CFBundleURLSchemes</key>
<array>
<string>listenbrainz</string>
</array>
</dict>
</array>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>org.listenbrainz.ios</string>
<key>CFBundleURLSchemes</key>
<array>
<string>listenbrainz</string>
</array>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>spotify</string>
</array>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
</dict>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>spotify</string>
</array>
</dict>
</plist>
81 changes: 44 additions & 37 deletions Listenbrainz/UI/Screens/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,51 @@ import SwiftUI
import UIKit

struct ContentView: View {

init() {
UITabBar.appearance().layer.borderColor = UIColor.clear.cgColor
UITabBar.appearance().clipsToBounds = true
}

var body: some View {
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house.fill")
}
PlayerView()
.edgesIgnoringSafeArea(.all)

.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height / 6, alignment: .center)

.tabItem {


Label("Player", systemImage: "opticaldisc.fill")
}
ListensView()
.tabItem {
Label("Listen", systemImage: "person.wave.2")
}

let screenWidth = UIScreen.main.bounds.size.width
let screenHeight = UIScreen.main.bounds.size.height

init() {
UITabBar.appearance().layer.borderColor = UIColor.clear.cgColor
UITabBar.appearance().clipsToBounds = true
}

var body: some View {
ZStack{
TabView {
HomeView()
.tabItem {
Label("Home", systemImage: "house.fill")
}
PlayerView()
.edgesIgnoringSafeArea(.all)

.frame(width: screenWidth, height: screenHeight, alignment: .center)

.tabItem {

ProfileView()
.frame(width: UIScreen.main.bounds.width, height: UIScreen.main.bounds.height / 6, alignment: .center)

.tabItem {

Label("Profile", systemImage: "beats.headphones")
}

}
.accentColor(Color.gray)
Label("Player", systemImage: "opticaldisc.fill")
}

ListensView()
.frame(width: screenWidth, height: screenHeight, alignment: .center)


.tabItem {
Label("Listens", systemImage: "person.wave.2")
}

ProfileView()
.frame(width: screenWidth, height: screenHeight, alignment: .center)

.tabItem {

Label("Profile", systemImage: "beats.headphones")
}

}
.accentColor(Color.gray)
}
}
}

42 changes: 28 additions & 14 deletions Listenbrainz/UI/Screens/ListensView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,41 @@
import SwiftUI

struct ListensView: View {
@ObservedObject var homeViewModel: HomeViewModel = HomeViewModel(repository: HomeRepositoryImpl())
@EnvironmentObject var spotifyManager: SpotifyManager
@State private var spotifyID: String = "https://open.spotify.com/track/0DHh3p0g7qmNNfNdRNwL6N"
@State private var maxTimeStamp:String = "john"
@State private var minTimeStamp:String = "123456"

var params: [String: String] {
return ["max_ts": maxTimeStamp, "min_ts":minTimeStamp]
}

var body: some View {
VStack {
TextField("Enter Spotify ID", text: $spotifyID)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()
NavigationView {
SongDetailView()
.environmentObject(homeViewModel)
}

Button(action: {
spotifyManager.playSong(spotifyID: spotifyID)
}) {
Text("Play Song")
.font(.headline)
.padding()
.background(Color.blue)
.foregroundColor(.white)
.cornerRadius(10)
}
// TextField("Enter Spotify ID", text: $spotifyID)
// .textFieldStyle(RoundedBorderTextFieldStyle())
// .padding()
//
// Button(action: {
// spotifyManager.playSong(spotifyID: spotifyID)
// }) {
// Text("Play Song")
// .font(.headline)
// .padding()
// .background(Color.blue)
// .foregroundColor(.white)
// .cornerRadius(10)
// }
}
.padding()



}
}

Expand Down