mirror of
https://github.com/msfjarvis/compose-lobsters
synced 2025-08-18 05:37:02 +05:30
Drop extra dependencies and host icon in-app
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
e6942fe353
commit
25ca5d52b2
4 changed files with 58 additions and 16 deletions
|
@ -52,24 +52,12 @@ dependencies {
|
||||||
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
|
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
|
||||||
implementation "androidx.compose.foundation:foundation-text:$compose_version"
|
implementation "androidx.compose.foundation:foundation-text:$compose_version"
|
||||||
implementation "androidx.compose.runtime:runtime:$compose_version"
|
implementation "androidx.compose.runtime:runtime:$compose_version"
|
||||||
implementation "androidx.compose.runtime:runtime-dispatch:$compose_version"
|
|
||||||
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
|
|
||||||
implementation "androidx.compose.runtime:runtime-rxjava2:$compose_version"
|
|
||||||
implementation "androidx.compose.runtime:runtime-saved-instance-state:$compose_version"
|
|
||||||
implementation "androidx.compose.material:material:$compose_version"
|
implementation "androidx.compose.material:material:$compose_version"
|
||||||
implementation "androidx.compose.material:material-icons-core:$compose_version"
|
|
||||||
implementation "androidx.compose.material:material-icons-extended:$compose_version"
|
|
||||||
implementation "androidx.compose:compose-compiler:$compose_version"
|
implementation "androidx.compose:compose-compiler:$compose_version"
|
||||||
implementation "androidx.compose.ui:ui:$compose_version"
|
implementation "androidx.compose.ui:ui:$compose_version"
|
||||||
implementation "androidx.compose.ui:ui-geometry:$compose_version"
|
|
||||||
implementation "androidx.compose.ui:ui-graphics:$compose_version"
|
|
||||||
implementation "androidx.compose.ui:ui-text:$compose_version"
|
implementation "androidx.compose.ui:ui-text:$compose_version"
|
||||||
implementation "androidx.compose.ui:ui-text-android:$compose_version"
|
implementation "androidx.compose.ui:ui-text-android:$compose_version"
|
||||||
implementation "androidx.compose.ui:ui-unit:$compose_version"
|
implementation "androidx.compose.ui:ui-unit:$compose_version"
|
||||||
implementation "androidx.compose.ui:ui-util:$compose_version"
|
|
||||||
implementation "androidx.compose.ui:ui-viewbinding:$compose_version"
|
|
||||||
implementation "androidx.compose.animation:animation:$compose_version"
|
|
||||||
implementation "androidx.compose.animation:animation-core:$compose_version"
|
|
||||||
implementation "androidx.ui:ui-tooling:$compose_version"
|
implementation "androidx.ui:ui-tooling:$compose_version"
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13'
|
||||||
androidTestImplementation 'androidx.test.ext:junit:1.1.2-alpha05'
|
androidTestImplementation 'androidx.test.ext:junit:1.1.2-alpha05'
|
||||||
|
|
|
@ -2,7 +2,6 @@ package dev.msfjarvis.todo
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.compose.foundation.Icon
|
|
||||||
import androidx.compose.foundation.Text
|
import androidx.compose.foundation.Text
|
||||||
import androidx.compose.foundation.layout.padding
|
import androidx.compose.foundation.layout.padding
|
||||||
import androidx.compose.foundation.lazy.LazyColumnFor
|
import androidx.compose.foundation.lazy.LazyColumnFor
|
||||||
|
@ -10,8 +9,6 @@ import androidx.compose.material.FloatingActionButton
|
||||||
import androidx.compose.material.MaterialTheme
|
import androidx.compose.material.MaterialTheme
|
||||||
import androidx.compose.material.Scaffold
|
import androidx.compose.material.Scaffold
|
||||||
import androidx.compose.material.TopAppBar
|
import androidx.compose.material.TopAppBar
|
||||||
import androidx.compose.material.icons.Icons
|
|
||||||
import androidx.compose.material.icons.filled.ExposurePlus1
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.mutableStateListOf
|
import androidx.compose.runtime.mutableStateListOf
|
||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
|
@ -20,6 +17,7 @@ import androidx.compose.ui.semantics.semantics
|
||||||
import androidx.compose.ui.semantics.testTag
|
import androidx.compose.ui.semantics.testTag
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
import androidx.ui.tooling.preview.Preview
|
import androidx.ui.tooling.preview.Preview
|
||||||
|
import dev.msfjarvis.todo.compose.utils.IconResource
|
||||||
import dev.msfjarvis.todo.data.model.TodoItem
|
import dev.msfjarvis.todo.data.model.TodoItem
|
||||||
import dev.msfjarvis.todo.ui.TodoRowItem
|
import dev.msfjarvis.todo.ui.TodoRowItem
|
||||||
import dev.msfjarvis.todo.ui.TodoTheme
|
import dev.msfjarvis.todo.ui.TodoTheme
|
||||||
|
@ -49,7 +47,10 @@ fun TodoApp() {
|
||||||
elevation = 8.dp,
|
elevation = 8.dp,
|
||||||
modifier = Modifier.semantics { testTag = "fab" }
|
modifier = Modifier.semantics { testTag = "fab" }
|
||||||
) {
|
) {
|
||||||
Icon(asset = Icons.Filled.ExposurePlus1, tint = MaterialTheme.colors.onSurface)
|
IconResource(
|
||||||
|
resourceId = R.drawable.ic_exposure_plus_1_24dp,
|
||||||
|
tint = MaterialTheme.colors.onSurface,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
bodyContent = {
|
bodyContent = {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020 Google LLC
|
||||||
|
*
|
||||||
|
* 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 dev.msfjarvis.todo.compose.utils
|
||||||
|
|
||||||
|
import androidx.annotation.DrawableRes
|
||||||
|
import androidx.compose.foundation.Icon
|
||||||
|
import androidx.compose.foundation.contentColor
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.DeferredResource
|
||||||
|
import androidx.compose.ui.res.loadVectorResource
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun IconResource(
|
||||||
|
@DrawableRes resourceId: Int,
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
tint: Color = contentColor()
|
||||||
|
) {
|
||||||
|
val deferredResource = loadVectorResource(resourceId)
|
||||||
|
deferredResource.onLoadRun { asset ->
|
||||||
|
Icon(asset = asset, modifier = modifier, tint = tint)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
inline fun <T> DeferredResource<T>.onLoadRun(block: (T) -> Unit) {
|
||||||
|
val res = resource.resource
|
||||||
|
if (res != null) {
|
||||||
|
block(res)
|
||||||
|
}
|
||||||
|
}
|
9
app/src/main/res/drawable/ic_exposure_plus_1_24dp.xml
Normal file
9
app/src/main/res/drawable/ic_exposure_plus_1_24dp.xml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:pathData="M10,7L8,7v4L4,11v2h4v4h2v-4h4v-2h-4L10,7zM20,18h-2L18,7.38L15,8.4L15,6.7L19.7,5h0.3v13z"
|
||||||
|
android:fillColor="#000000"/>
|
||||||
|
</vector>
|
Loading…
Add table
Add a link
Reference in a new issue