Skip to content

Commit

Permalink
Added IOS project.
Browse files Browse the repository at this point in the history
  • Loading branch information
AshuTyagi16 committed Jan 14, 2024
1 parent e4269db commit 3e6d39f
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 44 deletions.
100 changes: 99 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,102 @@ shared/core-network/build
shared/core-preferences/build
shared/feature-homepage/build
shared/feature-playlist-detail/build
shared/feature-album-detail/build
shared/feature-album-detail/build

#====================================

# Mac OS X Finder
Ios/Pods
Ios/Pods/Target Support Files/
Ios/Pods/Pods.xcodeproj/project.pbxproj
# Xcode
#
# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore

## User settings
Ios/xcuserdata/

## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9)
Ios/*.xcscmblueprint
Ios/*.xccheckout

## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4)
Ios/build/
Ios/DerivedData/
Ios/*.moved-aside
Ios/*.pbxuser
Ios/!default.pbxuser
Ios/*.mode1v3
Ios/!default.mode1v3
Ios/*.mode2v3
Ios/!default.mode2v3
Ios/*.perspectivev3
Ios/!default.perspectivev3

## Obj-C/Swift specific
Ios/*.hmap

## App packaging
Ios/*.ipa
Ios/*.dSYM.zip
Ios/*.dSYM

## Playgrounds
Ios/timeline.xctimeline
Ios/playground.xcworkspace

# Swift Package Manager
#
# Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
# Packages/
# Package.pins
# Package.resolved
# *.xcodeproj
#
# Xcode automatically generates this directory with a .xcworkspacedata file and xcuserdata
# hence it is not needed unless you have added a package configuration file to your project
# .swiftpm

Ios/.build/

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
#
Ios/Pods/
#
# Add this line if you want to avoid checking in source code from the Xcode workspace
# *.xcworkspace

# Carthage
#
# Add this line if you want to avoid checking in source code from Carthage dependencies.
# Carthage/Checkouts

Ios/Carthage/Build/

# Accio dependency management
Ios/Dependencies/
Ios/.accio/

# fastlane
#
# It is recommended to not store the screenshots in the git repo.
# Instead, use fastlane to re-generate the screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/#source-control

Ios/fastlane/report.xml
Ios/fastlane/Preview.html
Ios/fastlane/screenshots/**/*.png
Ios/fastlane/test_output

# Code Injection
#
# After new code Injection tools there's a generated folder /iOSInjectionProject
# https://github.com/johnno1962/injectionforxcode

Ios/iOSInjectionProject/
Ios/*.lock
1 change: 1 addition & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ import com.spotify.app.core_base.shared.domain.model.AlbumItem
import com.spotify.app.core_base.shared.util.BaseConstants
import com.spotify.app.feature_homepage.shared.ui.HomePageContract
import com.spotify.app.feature_homepage.shared.ui.HomePageViewModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch

@Composable
Expand Down Expand Up @@ -278,4 +277,4 @@ private fun HomePageSuccessStateComposable(
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ fun HomeScreenPlaceholder() {
}
}
}
}
}
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ targetSdkVersion = "34"

jvmTargetVersion = "1.8"

kotlinCompilerExtensionVersion = "1.5.7"
kotlinCompilerExtensionVersion = "1.5.8"

agp = "8.2.1"
kotlin = "1.9.22"
Expand Down
11 changes: 10 additions & 1 deletion shared/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import co.touchlab.skie.configuration.FlowInterop
import co.touchlab.skie.configuration.EnumInterop
import co.touchlab.skie.configuration.SealedInterop
import co.touchlab.skie.configuration.SuspendInterop
import org.jetbrains.kotlin.gradle.plugin.mpp.NativeBuildType

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
Expand Down Expand Up @@ -58,11 +61,14 @@ kotlin {
cocoapods {
summary = "Spotify Kmp Shared Binary"
homepage = "https://github.com/AshuTyagi16/Spotify-KMP"
ios.deploymentTarget = "13.5"
ios.deploymentTarget = "13.0"
extraSpecAttributes["libraries"] = "'c++', 'sqlite3'"
license = "BSD"
extraSpecAttributes["swift_version"] = "\"5.9.2\""
framework {

baseName = "shared"

// Shared Core Network Module
export(project(":shared:core-network"))

Expand Down Expand Up @@ -100,14 +106,17 @@ kmmbridge {
mavenPublishArtifacts()
spm()
cocoapods("[email protected]:AshuTyagi16/SpotifyKmpPodspec.git")
buildType.set(NativeBuildType.DEBUG)
}

skie {
features {
group {
FlowInterop.Enabled(true)
coroutinesInterop.set(true)
SuspendInterop.Enabled(true)
EnumInterop.Enabled(true)
SealedInterop.Enabled(true)
}
}
}
6 changes: 3 additions & 3 deletions shared/core-logger/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ buildkonfig {
exposeObjectWithName = "CoreLoggerBuildKonfig"

defaultConfigs {
buildConfigField(BOOLEAN, "DEBUG", "true")
buildConfigField(BOOLEAN, "IS_DEBUG", "true")
}

defaultConfigs("debug") {
buildConfigField(BOOLEAN, "DEBUG", "true")
buildConfigField(BOOLEAN, "IS_DEBUG", "true")
}

defaultConfigs("release") {
buildConfigField(BOOLEAN, "DEBUG", "false")
buildConfigField(BOOLEAN, "IS_DEBUG", "false")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import org.koin.dsl.module

val loggerModule = module {
single<LoggerApi> {
LoggerApiImpl(shouldEnableLogs = CoreLoggerBuildKonfig.DEBUG)
LoggerApiImpl(shouldEnableLogs = CoreLoggerBuildKonfig.IS_DEBUG)
}
}
6 changes: 3 additions & 3 deletions shared/core-network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ buildkonfig {
buildConfigField(STRING, "CLIENT_ID", tokenProperties["client_id"])
buildConfigField(STRING, "CLIENT_SECRET", tokenProperties["client_secret"])
buildConfigField(STRING, "GRANT_TYPE", tokenProperties["grant_type"])
buildConfigField(BOOLEAN, "DEBUG", "true")
buildConfigField(BOOLEAN, "IS_DEBUG", "true")
}

defaultConfigs("debug") {
buildConfigField(BOOLEAN, "DEBUG", "true")
buildConfigField(BOOLEAN, "IS_DEBUG", "true")
}

defaultConfigs("release") {
buildConfigField(BOOLEAN, "DEBUG", "false")
buildConfigField(BOOLEAN, "IS_DEBUG", "false")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.koin.dsl.module
val networkModule = module {
single<HttpClientApi> {
HttpClientApiImpl(
shouldEnableLogging = CoreNetworkBuildKonfig.DEBUG,
shouldEnableLogging = CoreNetworkBuildKonfig.IS_DEBUG,
json = get(),
loggerApi = get(),
preferenceUtilApi = get()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.spotify.app.feature_album_detail.shared.util

object FeatureAlbumDetailConstants {
const val QUALIFIER_ALBUM_DATABASE = "QUALIFIER_ALBUM_DATABASE"
const val ALBUM_DATABASE_NAME = "album_detail.db"
internal object FeatureAlbumDetailConstants {
internal const val QUALIFIER_ALBUM_DATABASE = "QUALIFIER_ALBUM_DATABASE"
internal const val ALBUM_DATABASE_NAME = "album_detail.db"
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.spotify.app.feature_homepage.shared.ui

import com.spotify.app.core_base.shared.domain.model.AlbumItem
import com.spotify.app.core_base.shared.ui.BaseViewModel
import com.spotify.app.core_base.shared.models.ViewModel
import com.spotify.app.core_network.shared.impl.data.model.RestClientResult
import com.spotify.app.core_network.shared.impl.util.isError
import com.spotify.app.core_network.shared.impl.util.isLoading
Expand All @@ -12,14 +12,32 @@ import com.spotify.app.core_network.shared.impl.util.onSuccess
import com.spotify.app.feature_homepage.shared.domain.model.playlist.PlaylistItem
import com.spotify.app.feature_homepage.shared.domain.use_case.FetchFeaturedAlbumsUseCase
import com.spotify.app.feature_homepage.shared.domain.use_case.FetchFeaturedPlaylistsUseCase
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharedFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
import kotlinx.coroutines.flow.combine

class HomePageViewModel(
private val fetchFeaturedPlaylistsUseCase: FetchFeaturedPlaylistsUseCase,
private val fetchFeaturedAlbumsUseCase: FetchFeaturedAlbumsUseCase
) : BaseViewModel<HomePageContract.Event, HomePageContract.State, HomePageContract.Effect>() {
) : ViewModel() {

private val currentState: HomePageContract.State
get() = uiState.value

private val _uiState: MutableStateFlow<HomePageContract.State> =
MutableStateFlow(createInitialState())
val uiState: StateFlow<HomePageContract.State>
get() = _uiState

private val _event: MutableSharedFlow<HomePageContract.Event> = MutableSharedFlow()

private val _effect: MutableSharedFlow<HomePageContract.Effect> = MutableSharedFlow()
val effect: SharedFlow<HomePageContract.Effect>
get() = _effect


suspend fun init() {
subscribeEvents()
Expand Down Expand Up @@ -73,20 +91,54 @@ class HomePageViewModel(
}
}

override fun createInitialState(): HomePageContract.State {
private fun createInitialState(): HomePageContract.State {
return HomePageContract.State(
HomePageContract.HomePageState.Idle
HomePageContract.HomePageState.Loading
)
}

override suspend fun handleEvent(event: HomePageContract.Event) {
private suspend fun handleEvent(event: HomePageContract.Event) {
when (event) {
HomePageContract.Event.OnFetchHomePageEvent -> {
fetchHomePageData()
}
}
}

/**
* Start listening to Event
*/
private suspend fun subscribeEvents() {
_event.collect {
handleEvent(it)
}
}


/**
* Set new Event
*/
suspend fun setEvent(event: HomePageContract.Event) {
_event.emit(event)
}


/**
* Set new Ui State
*/
private suspend fun setState(reduce: HomePageContract.State.() -> HomePageContract.State) {
val newState = currentState.reduce()
_uiState.emit(newState)
}

/**
* Set new Effect
*/
private suspend fun setEffect(builder: () -> HomePageContract.Effect) {
val effectValue = builder()
_effect.emit(effectValue)
}

override fun onCleared() {
super.onCleared()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package com.spotify.app.feature_homepage.shared.util

internal object FeatureHomePageConstants {

const val QUALIFIER_HOMEPAGE_DATABASE = "QUALIFIER_HOMEPAGE_DATABASE"
const val HOMEPAGE_DATABASE_NAME = "homepage.db"
internal const val QUALIFIER_HOMEPAGE_DATABASE = "QUALIFIER_HOMEPAGE_DATABASE"
internal const val HOMEPAGE_DATABASE_NAME = "homepage.db"

internal object Endpoints {
const val FETCH_FEATURED_PLAYLISTS = "v1/browse/featured-playlists"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.spotify.app.feature_playlist_detail.shared.util

object FeaturePlaylistDetailConstants {
const val QUALIFIER_PLAYLIST_DATABASE = "QUALIFIER_PLAYLIST_DATABASE"
const val PLAYLIST_DATABASE_NAME = "playlist_detail.db"
internal object FeaturePlaylistDetailConstants {
internal const val QUALIFIER_PLAYLIST_DATABASE = "QUALIFIER_PLAYLIST_DATABASE"
internal const val PLAYLIST_DATABASE_NAME = "playlist_detail.db"
}
2 changes: 1 addition & 1 deletion shared/shared.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Pod::Spec.new do |spec|
spec.summary = 'Spotify Kmp Shared Binary'
spec.vendored_frameworks = 'build/cocoapods/framework/shared.framework'

spec.ios.deployment_target = '13.5'
spec.ios.deployment_target = '13.0'


if !Dir.exist?('build/cocoapods/framework/shared.framework') || Dir.empty?('build/cocoapods/framework/shared.framework')
Expand Down

0 comments on commit 3e6d39f

Please sign in to comment.