Skip to content

Commit

Permalink
remove chart border and update example app
Browse files Browse the repository at this point in the history
  • Loading branch information
taewooyo committed Apr 17, 2024
1 parent 90b8202 commit 0129d2c
Show file tree
Hide file tree
Showing 19 changed files with 668 additions and 220 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
<br>
<p align="center">
<img src="https://github.com/taewooyo/volcano/assets/66770613/18a319ba-1570-4a11-9f71-e701bcc165da" width="280"/>
<img src="https://github.com/wisemuji/zoom-clone-compose/assets/167275873/d87d1583-30c2-407b-a61f-cdac4ed587e3" width="280"/>
<img src="https://github.com/wisemuji/zoom-clone-compose/assets/167275873/1db96251-72ec-4a94-8058-327ac0ef33a6" height="280"/>
<img src="https://github.com/taewooyo/volcano/assets/66770613/90d1a9b7-bdf4-488a-a326-2404f2d7e668" height="280"/>

</p>

## Volcano in Jetpack Compose
Expand Down
9 changes: 8 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import com.taewooyo.buildsrc.Configuration

@Suppress("DSL_SCOPE_VIOLATION") // TODO: Remove once KTIJ-19369 is fixed
plugins {
id(libs.plugins.android.application.get().pluginId)
id(libs.plugins.kotlin.android.get().pluginId)
id(libs.plugins.hilt.plugin.get().pluginId)
id(libs.plugins.ksp.get().pluginId)
}

android {
Expand Down Expand Up @@ -54,4 +55,10 @@ dependencies {
implementation(libs.androidx.compose.foundation)
implementation(libs.androidx.compose.runtime)
implementation(libs.androidx.compose.constraintlayout)
implementation(libs.androidx.hilt.navigation.compose)
implementation(libs.hilt.android)
ksp(libs.hilt.compiler)
implementation(libs.gson)
implementation(libs.androidx.lifecycle.runtimeCompose)
implementation(libs.androidx.lifecycle.viewModelCompose)
}
48 changes: 24 additions & 24 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
Designed and developed by 2023 taewooyo
Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -15,29 +14,30 @@
limitations under the License.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
xmlns:tools="http://schemas.android.com/tools">

<application
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Volcano"
tools:targetApi="31">
<activity
android:name="com.taewooyo.volcano.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Volcano">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<application
android:name=".MainApplication"
android:allowBackup="true"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Volcano"
tools:targetApi="31">
<activity
android:name="com.taewooyo.volcano.ui.MainActivity"
android:exported="true"
android:label="@string/app_name"
android:theme="@style/Theme.Volcano">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

</manifest>
394 changes: 394 additions & 0 deletions app/src/main/assets/stock.json

Large diffs are not rendered by default.

21 changes: 7 additions & 14 deletions app/src/main/kotlin/com/taewooyo/volcano/Colors.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb

internal fun getColor(percentage: Double): Int = when {
percentage < -30.0 -> Color(0xFFFCB9AA).toArgb()
percentage < -25.0 -> Color(0xFFFFDBCC).toArgb()
percentage < -20.0 -> Color(0xFFECEAE4).toArgb()
percentage < -15.0 -> Color(0xFFA2E1DB).toArgb()
percentage < -10.0 -> Color(0xFF55CBCD).toArgb()
percentage < -5.0 -> Color(0xFFABDEE6).toArgb()
percentage < 0.0 -> Color(0xFFCBAACB).toArgb()
percentage < 5.0 -> Color(0xFFE4AE9D).toArgb()
percentage < 10.0 -> Color(0xFFE1CCB6).toArgb()
percentage < 15.0 -> Color(0xFFF3B0C3).toArgb()
percentage < 20.0 -> Color(0xFF4b8f82).toArgb()
percentage < 25.0 -> Color(0xFFC08863).toArgb()
percentage < 30.0 -> Color(0xFF5AA08D).toArgb()
percentage < 35.0 -> Color(0xFFEF84C1).toArgb()
percentage < -30.0 -> Color(0xFF9a1f29).toArgb()
percentage < -20.0 -> Color(0xFFf23645).toArgb()
percentage < -10.0 -> Color(0xFFf77c80).toArgb()
percentage < 0.0 -> Color(0xFFc2c4cd).toArgb()
percentage < 10.0 -> Color(0xFF43bd7f).toArgb()
percentage < 20.0 -> Color(0xFF049950).toArgb()
percentage < 30.0 -> Color(0xFF076636).toArgb()
else -> Color(0xFFFC9ABB).toArgb()
}
129 changes: 0 additions & 129 deletions app/src/main/kotlin/com/taewooyo/volcano/Dummy.kt

This file was deleted.

7 changes: 7 additions & 0 deletions app/src/main/kotlin/com/taewooyo/volcano/MainApplication.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.taewooyo.volcano

import android.app.Application
import dagger.hilt.android.HiltAndroidApp

@HiltAndroidApp
class MainApplication : Application()
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.taewooyo.volcano.core.assets

import android.content.Context
import javax.inject.Inject

class AssetLoader @Inject constructor(private val context: Context) {
fun getJsonString(fileName: String): String? {
return runCatching {
loadAsset(fileName)
}.getOrNull()
}

private fun loadAsset(fileName: String): String {
return context.assets.open(fileName).use { inputStream ->
val size = inputStream.available()
val bytes = ByteArray(size)
inputStream.read(bytes)
String(bytes)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.taewooyo.volcano.core.assets.di

import android.content.Context
import com.taewooyo.volcano.core.assets.AssetLoader
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
internal object AssetModule {

@Provides
@Singleton
fun provideAssetLoader(@ApplicationContext context: Context): AssetLoader = AssetLoader(context)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.taewooyo.volcano.core.data.di

import com.taewooyo.volcano.core.data.stock.StockRepository
import com.taewooyo.volcano.core.data.stock.StockRepositoryImpl
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
internal interface DataModule {

@Binds
fun bindsStockRepository(stockRepositoryImpl: StockRepositoryImpl): StockRepository
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.taewooyo.volcano.core.data.stock

import com.taewooyo.volcano.core.model.Stocks
import kotlinx.coroutines.flow.Flow

interface StockRepository {

fun fetchStockList(): Stocks?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.taewooyo.volcano.core.data.stock

import com.google.gson.Gson
import com.taewooyo.volcano.core.assets.AssetLoader
import com.taewooyo.volcano.core.model.Stocks
import javax.inject.Inject

class StockRepositoryImpl @Inject constructor(
private val assetLoader: AssetLoader
) : StockRepository {
override fun fetchStockList(): Stocks? {
val gson = Gson()
return assetLoader.getJsonString("stock.json")?.let { jsonString ->
gson.fromJson(jsonString, Stocks::class.java)
}
}
}
27 changes: 27 additions & 0 deletions app/src/main/kotlin/com/taewooyo/volcano/core/model/StockItem.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (C) 2023 taewooyo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.taewooyo.volcano.core.model

data class Stocks(
val stocks: List<StockItem>
)

data class StockItem(
val name: String,
val value: Double,
val oldValue: Double,
val type: String,
)
Loading

0 comments on commit 0129d2c

Please sign in to comment.