├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml └── misc.xml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── atilsamancioglu │ │ └── composeretro │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── atilsamancioglu │ │ │ └── composeretro │ │ │ ├── MainActivity.kt │ │ │ ├── model │ │ │ └── CryptoModel.kt │ │ │ ├── service │ │ │ └── CryptoAPI.kt │ │ │ └── ui │ │ │ └── theme │ │ │ ├── Color.kt │ │ │ ├── Shape.kt │ │ │ ├── Theme.kt │ │ │ └── Type.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.webp │ │ └── ic_launcher_round.webp │ │ ├── values-night │ │ └── themes.xml │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── themes.xml │ └── test │ └── java │ └── com │ └── atilsamancioglu │ └── composeretro │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | local.properties 16 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.application' 3 | id 'kotlin-android' 4 | } 5 | 6 | android { 7 | compileSdk 30 8 | buildToolsVersion "30.0.3" 9 | 10 | defaultConfig { 11 | applicationId "com.atilsamancioglu.composeretro" 12 | minSdk 23 13 | targetSdk 30 14 | versionCode 1 15 | versionName "1.0" 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | buildTypes { 21 | release { 22 | minifyEnabled false 23 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 24 | } 25 | } 26 | compileOptions { 27 | sourceCompatibility JavaVersion.VERSION_1_8 28 | targetCompatibility JavaVersion.VERSION_1_8 29 | } 30 | kotlinOptions { 31 | jvmTarget = '1.8' 32 | useIR = true 33 | } 34 | buildFeatures { 35 | compose true 36 | } 37 | composeOptions { 38 | kotlinCompilerExtensionVersion compose_version 39 | kotlinCompilerVersion '1.4.30' 40 | } 41 | } 42 | def retrofitVersion = '2.9.0' 43 | 44 | dependencies { 45 | 46 | implementation 'androidx.core:core-ktx:1.3.2' 47 | implementation 'androidx.appcompat:appcompat:1.2.0' 48 | implementation 'com.google.android.material:material:1.3.0' 49 | implementation "androidx.compose.ui:ui:$compose_version" 50 | implementation "androidx.compose.material:material:$compose_version" 51 | implementation "androidx.compose.ui:ui-tooling:$compose_version" 52 | implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.3.1' 53 | implementation 'androidx.activity:activity-compose:1.3.0-alpha05' 54 | testImplementation 'junit:junit:4.+' 55 | androidTestImplementation 'androidx.test.ext:junit:1.1.2' 56 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0' 57 | androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version" 58 | 59 | implementation "com.squareup.retrofit2:retrofit:$retrofitVersion" 60 | implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion" 61 | implementation "com.squareup.retrofit2:adapter-rxjava2:$retrofitVersion" 62 | 63 | 64 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1' 65 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.1' 66 | } -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile -------------------------------------------------------------------------------- /app/src/androidTest/java/com/atilsamancioglu/composeretro/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.ext.junit.runners.AndroidJUnit4 5 | 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | import org.junit.Assert.* 10 | 11 | /** 12 | * Instrumented test, which will execute on an Android device. 13 | * 14 | * See [testing documentation](http://d.android.com/tools/testing). 15 | */ 16 | @RunWith(AndroidJUnit4::class) 17 | class ExampleInstrumentedTest { 18 | @Test 19 | fun useAppContext() { 20 | // Context of the app under test. 21 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 22 | assertEquals("com.atilsamancioglu.composeretro", appContext.packageName) 23 | } 24 | } -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 14 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro 2 | 3 | import android.os.Bundle 4 | import androidx.activity.ComponentActivity 5 | import androidx.activity.compose.setContent 6 | import androidx.compose.foundation.background 7 | import androidx.compose.foundation.layout.* 8 | import androidx.compose.foundation.lazy.LazyColumn 9 | import androidx.compose.material.* 10 | import androidx.compose.runtime.Composable 11 | import androidx.compose.ui.tooling.preview.Preview 12 | import androidx.compose.ui.unit.dp 13 | import androidx.compose.ui.unit.sp 14 | import com.atilsamancioglu.composeretro.model.CryptoModel 15 | import com.atilsamancioglu.composeretro.service.CryptoAPI 16 | import com.atilsamancioglu.composeretro.ui.theme.ComposeRetroTheme 17 | import retrofit2.Retrofit 18 | import retrofit2.converter.gson.GsonConverterFactory 19 | import androidx.compose.foundation.lazy.items 20 | import androidx.compose.runtime.mutableStateListOf 21 | import androidx.compose.runtime.remember 22 | import androidx.compose.ui.Modifier 23 | import androidx.compose.ui.graphics.Color 24 | import androidx.compose.ui.text.TextStyle 25 | import androidx.compose.ui.text.font.FontWeight 26 | import retrofit2.Call 27 | import retrofit2.Callback 28 | import retrofit2.Response 29 | 30 | class MainActivity : ComponentActivity() { 31 | 32 | private val BASE_URL = "https://raw.githubusercontent.com/" 33 | 34 | override fun onCreate(savedInstanceState: Bundle?) { 35 | super.onCreate(savedInstanceState) 36 | 37 | setContent { 38 | ComposeRetroTheme { 39 | MainScreen() 40 | } 41 | } 42 | } 43 | 44 | 45 | @Composable 46 | fun MainScreen() { 47 | var cryptoModels = remember { mutableStateListOf() } 48 | 49 | val retrofit = Retrofit.Builder() 50 | .baseUrl(BASE_URL) 51 | .addConverterFactory(GsonConverterFactory.create()) 52 | .build() 53 | .create(CryptoAPI::class.java) 54 | 55 | val call = retrofit.getData() 56 | 57 | call.enqueue(object: Callback> { 58 | override fun onFailure(call: Call>, t: Throwable) { 59 | t.printStackTrace() 60 | } 61 | override fun onResponse( 62 | call: Call>, 63 | response: Response> 64 | ) { 65 | if (response.isSuccessful) { 66 | response.body()?.let { 67 | cryptoModels.addAll(it) 68 | } 69 | } 70 | } 71 | }) 72 | 73 | Scaffold(topBar = { AppBar() }) { 74 | Surface(color = MaterialTheme.colors.surface) { 75 | CryptoList(cryptos = cryptoModels) 76 | } 77 | } 78 | } 79 | } 80 | 81 | @Composable 82 | fun AppBar() { 83 | TopAppBar(elevation = 10.dp,contentPadding = PaddingValues(15.dp)) { 84 | Text(text = "Retro Compose",fontSize = 26.sp) 85 | } 86 | } 87 | 88 | @Composable 89 | fun CryptoList(cryptos: List) { 90 | LazyColumn(contentPadding = PaddingValues(5.dp)) { 91 | items(cryptos) { crypto -> 92 | CryptoRow(crypto = crypto) 93 | } 94 | } 95 | } 96 | 97 | @Composable 98 | fun CryptoRow(crypto: CryptoModel) { 99 | Column(modifier = Modifier.fillMaxWidth().background(color = MaterialTheme.colors.surface)) { 100 | Text(text = crypto.currency, 101 | style = MaterialTheme.typography.h4, 102 | modifier = Modifier.padding(2.dp), 103 | fontWeight = FontWeight.Bold 104 | ) 105 | Text(text = crypto.price, 106 | style = MaterialTheme.typography.h5, 107 | modifier = Modifier.padding(2.dp)) 108 | } 109 | } 110 | 111 | @Preview(showBackground = true) 112 | @Composable 113 | fun DefaultPreview() { 114 | ComposeRetroTheme { 115 | CryptoRow(CryptoModel("BTC","50000")) 116 | } 117 | } -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/model/CryptoModel.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.model 2 | 3 | data class CryptoModel( 4 | val currency: String, 5 | val price: String 6 | ) 7 | 8 | -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/service/CryptoAPI.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.service 2 | 3 | import com.atilsamancioglu.composeretro.model.CryptoModel 4 | import retrofit2.Call 5 | import retrofit2.Response 6 | import retrofit2.http.GET 7 | 8 | interface CryptoAPI { 9 | 10 | @GET("atilsamancioglu/K21-JSONDataSet/master/crypto.json") 11 | fun getData(): Call> 12 | 13 | } 14 | -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/ui/theme/Color.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.ui.theme 2 | 3 | import androidx.compose.ui.graphics.Color 4 | 5 | val Purple200 = Color(0xFFBB86FC) 6 | val Purple500 = Color(0xFF6200EE) 7 | val Purple700 = Color(0xFF3700B3) 8 | val Teal200 = Color(0xFF03DAC5) -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/ui/theme/Shape.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.ui.theme 2 | 3 | import androidx.compose.foundation.shape.RoundedCornerShape 4 | import androidx.compose.material.Shapes 5 | import androidx.compose.ui.unit.dp 6 | 7 | val Shapes = Shapes( 8 | small = RoundedCornerShape(4.dp), 9 | medium = RoundedCornerShape(4.dp), 10 | large = RoundedCornerShape(0.dp) 11 | ) -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/ui/theme/Theme.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.ui.theme 2 | 3 | import androidx.compose.foundation.isSystemInDarkTheme 4 | import androidx.compose.material.MaterialTheme 5 | import androidx.compose.material.darkColors 6 | import androidx.compose.material.lightColors 7 | import androidx.compose.runtime.Composable 8 | import androidx.compose.ui.graphics.Color 9 | 10 | private val DarkColorPalette = darkColors( 11 | primary = Purple200, 12 | primaryVariant = Purple700, 13 | secondary = Teal200 14 | ) 15 | 16 | private val LightColorPalette = lightColors( 17 | primary = Purple500, 18 | primaryVariant = Purple700, 19 | secondary = Teal200, 20 | background = Color.White, 21 | surface = Color.LightGray, 22 | onPrimary = Color.White, 23 | onSecondary = Color.Black, 24 | onBackground = Color.Black, 25 | onSurface = Color.Black, 26 | 27 | ) 28 | 29 | @Composable 30 | fun ComposeRetroTheme( 31 | darkTheme: Boolean = isSystemInDarkTheme(), 32 | content: @Composable() () -> Unit 33 | ) { 34 | val colors = if (darkTheme) { 35 | DarkColorPalette 36 | } else { 37 | LightColorPalette 38 | } 39 | 40 | MaterialTheme( 41 | colors = colors, 42 | typography = Typography, 43 | shapes = Shapes, 44 | content = content 45 | ) 46 | } -------------------------------------------------------------------------------- /app/src/main/java/com/atilsamancioglu/composeretro/ui/theme/Type.kt: -------------------------------------------------------------------------------- 1 | package com.atilsamancioglu.composeretro.ui.theme 2 | 3 | import androidx.compose.material.Typography 4 | import androidx.compose.ui.text.TextStyle 5 | import androidx.compose.ui.text.font.FontFamily 6 | import androidx.compose.ui.text.font.FontWeight 7 | import androidx.compose.ui.unit.sp 8 | 9 | // Set of Material typography styles to start with 10 | val Typography = Typography( 11 | body1 = TextStyle( 12 | fontFamily = FontFamily.Default, 13 | fontWeight = FontWeight.Normal, 14 | fontSize = 16.sp 15 | ) 16 | /* Other default text styles to override 17 | button = TextStyle( 18 | fontFamily = FontFamily.Default, 19 | fontWeight = FontWeight.W500, 20 | fontSize = 14.sp 21 | ), 22 | caption = TextStyle( 23 | fontFamily = FontFamily.Default, 24 | fontWeight = FontWeight.Normal, 25 | fontSize = 12.sp 26 | ) 27 | */ 28 | ) -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-hdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-mdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atilsamancioglu/A45-ComposeRetro/0ce4103e0cf5e043c213b5e8260c038dda3d1cf1/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp -------------------------------------------------------------------------------- /app/src/main/res/values-night/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #FFBB86FC 4 | #FF6200EE 5 | #FF3700B3 6 | #FF03DAC5 7 | #FF018786 8 | #FF000000 9 | #FFFFFFFF 10 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | ComposeRetro 3 | -------------------------------------------------------------------------------- /app/src/main/res/values/themes.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 21 | 22 |