Skip to content

Commit

Permalink
Code Cleaned & Ktlint Added
Browse files Browse the repository at this point in the history
  • Loading branch information
Shabinder committed Mar 19, 2021
1 parent 46e5e89 commit ccea676
Show file tree
Hide file tree
Showing 144 changed files with 1,711 additions and 1,405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ import com.shabinder.common.models.TrackDetails
import com.shabinder.common.root.SpotiFlyerRoot
import com.shabinder.common.root.callbacks.SpotiFlyerRootCallBacks
import com.shabinder.common.uikit.*
import com.shabinder.database.Database
import com.shabinder.spotiflyer.utils.*
import com.tonyodev.fetch2.Status
import kotlinx.coroutines.*
Expand Down
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

plugins {
`kotlin-dsl`
id("org.jlleitschuh.gradle.ktlint")
id("org.jlleitschuh.gradle.ktlint-idea")
}

allprojects {
Expand All @@ -27,7 +29,7 @@ allprojects {
maven(url = "https://dl.bintray.com/ekito/koin")
maven(url = "https://kotlin.bintray.com/kotlinx/")
maven(url = "https://dl.bintray.com/icerockdev/moko")
//maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers/")
// maven(url = "https://kotlin.bintray.com/kotlin-js-wrappers/")
maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers")
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
Expand Down
5 changes: 3 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

plugins {
`kotlin-dsl`
//`kotlin-dsl-precompiled-script-plugins`
}

group = "com.shabinder"
Expand All @@ -28,6 +27,7 @@ repositories {
mavenCentral()
google()
maven(url = "https://jitpack.io")
maven(url = "https://plugins.gradle.org/m2/")
maven(url = "https://dl.bintray.com/kotlin/kotlin-js-wrappers")
maven(url = "https://maven.pkg.jetbrains.space/public/p/compose/dev")
}
Expand All @@ -37,6 +37,7 @@ dependencies {
implementation("com.google.gms:google-services:4.3.5")
implementation("com.google.firebase:perf-plugin:1.3.5")
implementation("com.google.firebase:firebase-crashlytics-gradle:2.5.1")
implementation("org.jlleitschuh.gradle:ktlint-gradle:${Versions.ktLint}")
implementation(JetBrains.Compose.gradlePlugin)
implementation(JetBrains.Kotlin.gradlePlugin)
implementation(JetBrains.Kotlin.serialization)
Expand All @@ -50,4 +51,4 @@ kotlinDslPluginOptions {
kotlin {
// Add Deps to compilation, so it will become available in main project
sourceSets.getByName("main").kotlin.srcDir("buildSrc/src/main/kotlin")
}
}
19 changes: 11 additions & 8 deletions buildSrc/buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,29 @@ object Versions {
const val kotlinVersion = "1.4.31"

const val coroutinesVersion = "1.4.2"
//const val compose = "1.0.0-alpha12"

const val coilVersion = "0.4.1"
//DI

// Code Formatting
const val ktLint = "10.0.0"

// DI
const val koin = "3.0.1-beta-1"

//Logger
// Logger
const val kermit = "0.1.8"

//Internet
// Internet
const val ktor = "1.5.2"

const val kotlinxSerialization = "1.1.0-RC"
//Database
// Database
const val sqlDelight = "1.4.4"

const val sqliteJdbcDriver = "3.30.1"
const val slf4j = "1.7.30"

//Android
// Android
const val versionCode = 15
const val minSdkVersion = 24
const val compileSdkVersion = 29
Expand All @@ -53,7 +56,7 @@ object Koin {
val android = "io.insert-koin:koin-android:${Versions.koin}"
val compose = "io.insert-koin:koin-androidx-compose:${Versions.koin}"
}
object Androidx{
object Androidx {
const val androidxActivity = "androidx.activity:activity-compose:1.3.0-alpha02"
const val core = "androidx.core:core-ktx:1.3.2"
const val palette = "androidx.palette:palette-ktx:1.0.0"
Expand Down Expand Up @@ -162,4 +165,4 @@ object SqlDelight {
const val nativeDriver = "com.squareup.sqldelight:native-driver:${Versions.sqlDelight}"
val nativeDriverMacos = "com.squareup.sqldelight:native-driver-macosx64:${Versions.sqlDelight}"
val jdbcDriver = "org.xerial:sqlite-jdbc:${Versions.sqliteJdbcDriver}"
}
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/android-setup.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

plugins {
id("com.android.library")
id("ktlint-setup")
}

android {
Expand Down Expand Up @@ -43,5 +44,4 @@ android {
res.srcDirs("src/androidMain/res")
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,31 @@
* * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

package com.shabinder.common.di
plugins {
id("org.jlleitschuh.gradle.ktlint")
id("org.jlleitschuh.gradle.ktlint-idea")
}

sealed class NetworkResponse<out T> {
data class Success<T>(val value:T):NetworkResponse<T>()
data class Error(val message:String):NetworkResponse<Nothing>()
subprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
apply(plugin = "org.jlleitschuh.gradle.ktlint-idea")
repositories {
// Required to download KtLint
mavenCentral()
}
ktlint {
android.set(true)
outputToConsole.set(true)
ignoreFailures.set(true)
coloredOutput.set(true)
verbose.set(true)
filter {
exclude("**/generated/**")
exclude("**/build/**")
}
}
// Optionally configure plugin
/*configure<org.jlleitschuh.gradle.ktlint.KtlintExtension> {
debug.set(true)
}*/
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ plugins {
id("com.android.library")
id("kotlin-multiplatform")
id("org.jetbrains.compose")
id("ktlint-setup")
}

kotlin {
Expand Down
9 changes: 4 additions & 5 deletions buildSrc/src/main/kotlin/multiplatform-setup-test.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@
plugins {
id("com.android.library")
id("kotlin-multiplatform")
id("ktlint-setup")
}

kotlin {
jvm("desktop")
android()
//ios()
// ios()
js() {
browser()
//nodejs()
// nodejs()
binaries.executable()
}
sourceSets {
Expand All @@ -47,9 +48,7 @@ kotlin {
}
}
named("jsTest") {
dependencies {

}
dependencies {}
}
}

Expand Down
14 changes: 3 additions & 11 deletions buildSrc/src/main/kotlin/multiplatform-setup.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,32 +14,24 @@
* * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import gradle.kotlin.dsl.accessors._2e23d8fadf0ed92ae13e19db3d83f86d.compose
import gradle.kotlin.dsl.accessors._2e23d8fadf0ed92ae13e19db3d83f86d.kotlin
import gradle.kotlin.dsl.accessors._2e23d8fadf0ed92ae13e19db3d83f86d.sourceSets
import org.gradle.kotlin.dsl.withType
import org.jetbrains.compose.compose

plugins {
// id("com.android.library")
id("android-setup")
id("kotlin-multiplatform")
id("org.jetbrains.compose")
id("ktlint-setup")
}

kotlin {
jvm("desktop")
android()
js() {
browser()
//nodejs()
// nodejs()
binaries.executable()
}
sourceSets {
named("commonMain") {
dependencies {

}
dependencies {}
}

named("androidMain") {
Expand Down
2 changes: 1 addition & 1 deletion common/compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ kotlin {
implementation(project(":common:database"))
implementation(project(":common:data-models"))
implementation(project(":common:dependency-injection"))
//DECOMPOSE
// DECOMPOSE
implementation(Decompose.decompose)
implementation(Decompose.extensionsCompose)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@ package com.shabinder.common.uikit
import androidx.annotation.DrawableRes
import androidx.compose.animation.Crossfade
import androidx.compose.foundation.Image
import androidx.compose.runtime.*
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.MutableState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.ImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector
Expand All @@ -39,21 +45,21 @@ import kotlinx.coroutines.withContext

@Composable
actual fun ImageLoad(
link:String,
loader:suspend (String) -> Picture,
link: String,
loader: suspend (String) -> Picture,
desc: String,
modifier:Modifier,
//placeholder: ImageVector
modifier: Modifier,
// placeholder: ImageVector
) {
var pic by remember(link) { mutableStateOf<ImageBitmap?>(null) }
LaunchedEffect(link){
LaunchedEffect(link) {
withContext(dispatcherIO) {
pic = loader(link).image
}
}

Crossfade(pic){
if(it == null) Image(PlaceHolderImage(), desc, modifier,contentScale = ContentScale.Crop) else Image(it, desc, modifier,contentScale = ContentScale.Crop)
Crossfade(pic) {
if (it == null) Image(PlaceHolderImage(), desc, modifier, contentScale = ContentScale.Crop) else Image(it, desc, modifier, contentScale = ContentScale.Crop)
}
}

Expand All @@ -68,25 +74,24 @@ actual fun pristineFont() = FontFamily(
Font(R.font.pristine_script, FontWeight.Bold)
)


@Composable
actual fun DownloadImageTick(){
actual fun DownloadImageTick() {
Image(
painterResource(R.drawable.ic_tick),
"Download Done"
)
}

@Composable
actual fun DownloadImageError(){
actual fun DownloadImageError() {
Image(
painterResource(R.drawable.ic_error),
"Error! Cant Download this track"
)
}

@Composable
actual fun DownloadImageArrow(modifier: Modifier){
actual fun DownloadImageArrow(modifier: Modifier) {
Image(
painterResource(R.drawable.ic_arrow),
"Start Download",
Expand Down Expand Up @@ -125,16 +130,16 @@ actual fun YoutubeMusicLogo() = vectorResource(R.drawable.ic_youtube_music_logo)
actual fun GithubLogo() = vectorResource(R.drawable.ic_github)

@Composable
fun vectorResource(@DrawableRes id: Int) = ImageVector.Companion.vectorResource(id)
fun vectorResource(@DrawableRes id: Int) = ImageVector.Companion.vectorResource(id)

@Composable
actual fun Toast(
text: String,
visibility: MutableState<Boolean>,
duration: ToastDuration
){
//We Have Android's Implementation of Toast so its just Empty
) {
// We Have Android's Implementation of Toast so its just Empty
}
actual fun showPopUpMessage(text: String) {
android.widget.Toast.makeText(appContext, text, android.widget.Toast.LENGTH_SHORT).show()
}
actual fun showPopUpMessage(text: String){
android.widget.Toast.makeText(appContext,text, android.widget.Toast.LENGTH_SHORT).show()
}
Loading

0 comments on commit ccea676

Please sign in to comment.