Skip to content

Commit 1f4a1c6

Browse files
konstantiniivuburoiubu
authored andcommitted
DROID-3612 Widgets | Icon fixes (#2371)
1 parent 5c090be commit 1f4a1c6

File tree

8 files changed

+41
-14
lines changed

8 files changed

+41
-14
lines changed

app/src/main/java/com/anytypeio/anytype/ui/widgets/types/ListWidget.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ fun CompactListWidgetList(
176176
.padding(start = 0.dp, end = 4.dp),
177177
onTaskIconClicked = { isChecked ->
178178
onObjectCheckboxClicked(element.obj.id, isChecked)
179-
}
179+
},
180+
iconWithoutBackgroundMaxSize = 200.dp,
181+
imageMultiplier = 1.0f
180182
)
181183
Text(
182184
text = element.getPrettyName(),

app/src/main/java/com/anytypeio/anytype/ui/widgets/types/TreeWidget.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ private fun TreeWidgetTreeItems(
170170
Modifier.noRippleClickable { onWidgetElementClicked(element.obj) }
171171
else
172172
Modifier
173-
)
173+
),
174+
verticalAlignment = Alignment.CenterVertically
174175
) {
175176
if (element.indent > 0) {
176177
Spacer(
@@ -224,6 +225,8 @@ private fun TreeWidgetTreeItems(
224225
ListWidgetObjectIcon(
225226
iconSize = 18.dp,
226227
icon = element.objectIcon,
228+
imageMultiplier = 1.0f,
229+
iconWithoutBackgroundMaxSize = 200.dp,
227230
modifier = Modifier.align(Alignment.CenterVertically).padding(start = 8.dp, end = 4.dp),
228231
onTaskIconClicked = { isChecked ->
229232
onObjectCheckboxClicked(element.id, isChecked)

core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/ObjectIconCompose.kt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ fun ListWidgetObjectIcon(
2828
icon: ObjectIcon,
2929
modifier: Modifier,
3030
iconSize: Dp = 48.dp,
31+
imageMultiplier: Float = 0.625f,
32+
iconWithoutBackgroundMaxSize: Dp = 20.dp,
3133
onTaskIconClicked: (Boolean) -> Unit = {},
3234
backgroundColor: Int = R.color.shape_tertiary
3335
) {
@@ -45,7 +47,9 @@ fun ListWidgetObjectIcon(
4547
icon = icon,
4648
backgroundSize = iconSize,
4749
modifier = modifier,
48-
backgroundColor = backgroundColor
50+
backgroundColor = backgroundColor,
51+
imageMultiplier = imageMultiplier,
52+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
4953
)
5054
}
5155

@@ -54,14 +58,18 @@ fun ListWidgetObjectIcon(
5458
icon = icon,
5559
backgroundSize = iconSize,
5660
modifier = modifier,
61+
imageMultiplier = imageMultiplier,
62+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
5763
)
5864
}
5965

6066
is ObjectIcon.Bookmark -> {
6167
BookmarkIconView(
6268
modifier = modifier,
6369
icon = icon,
64-
backgroundSize = iconSize
70+
backgroundSize = iconSize,
71+
imageMultiplier = imageMultiplier,
72+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
6573
)
6674
}
6775

@@ -95,7 +103,9 @@ fun ListWidgetObjectIcon(
95103
icon = icon,
96104
backgroundSize = iconSize,
97105
modifier = modifier,
98-
backgroundColor = backgroundColor
106+
backgroundColor = backgroundColor,
107+
imageMultiplier = imageMultiplier,
108+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
99109
)
100110

101111
is ObjectIcon.Checkbox -> {

core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/objectIcon/BookmarkIconView.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ import com.anytypeio.anytype.presentation.objects.ObjectIcon
1919
fun BookmarkIconView(
2020
modifier: Modifier = Modifier,
2121
icon: ObjectIcon.Bookmark,
22+
imageMultiplier: Float,
2223
backgroundSize: Dp,
24+
iconWithoutBackgroundMaxSize: Dp
2325
) {
2426

2527
val painter = rememberAsyncImagePainter(model = icon.image)
@@ -37,7 +39,9 @@ fun BookmarkIconView(
3739
TypeIconView(
3840
modifier = modifier,
3941
icon = icon.fallback,
40-
backgroundSize = backgroundSize
42+
backgroundSize = backgroundSize,
43+
imageMultiplier = imageMultiplier,
44+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
4145
)
4246
}
4347
is AsyncImagePainter.State.Success -> {

core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/objectIcon/EmojiIconView.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import androidx.compose.ui.Alignment
1010
import androidx.compose.ui.Modifier
1111
import androidx.compose.ui.res.colorResource
1212
import androidx.compose.ui.unit.Dp
13-
import androidx.compose.ui.unit.dp
1413
import coil3.compose.rememberAsyncImagePainter
1514
import com.anytypeio.anytype.core_ui.R
1615
import com.anytypeio.anytype.core_ui.widgets.cornerRadius
@@ -22,8 +21,8 @@ fun EmojiIconView(
2221
modifier: Modifier = Modifier,
2322
icon: ObjectIcon.Basic.Emoji,
2423
backgroundSize: Dp,
25-
iconWithoutBackgroundMaxSize: Dp = 20.dp,
26-
imageMultiplier: Float = 0.625f,
24+
iconWithoutBackgroundMaxSize: Dp,
25+
imageMultiplier: Float,
2726
backgroundColor: Int = R.color.shape_tertiary
2827
) {
2928
val (containerModifier, iconModifier) = if (backgroundSize > iconWithoutBackgroundMaxSize) {
@@ -60,7 +59,9 @@ fun EmojiIconView(
6059
TypeIconView(
6160
modifier = modifier,
6261
icon = icon.fallback,
63-
backgroundSize = backgroundSize
62+
backgroundSize = backgroundSize,
63+
imageMultiplier = imageMultiplier,
64+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
6465
)
6566
}
6667
}

core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/objectIcon/ImageIconView.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ import com.bumptech.glide.integration.compose.ExperimentalGlideComposeApi
2121
fun ImageIconView(
2222
modifier: Modifier = Modifier,
2323
icon: ObjectIcon.Basic.Image,
24+
imageMultiplier: Float,
25+
iconWithoutBackgroundMaxSize: Dp,
2426
backgroundSize: Dp
2527
) {
2628

@@ -40,7 +42,9 @@ fun ImageIconView(
4042
TypeIconView(
4143
modifier = modifier,
4244
icon = icon.fallback,
43-
backgroundSize = backgroundSize
45+
backgroundSize = backgroundSize,
46+
imageMultiplier = imageMultiplier,
47+
iconWithoutBackgroundMaxSize = iconWithoutBackgroundMaxSize
4448
)
4549
}
4650

core-ui/src/main/java/com/anytypeio/anytype/core_ui/widgets/objectIcon/TypeIconView.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ fun TypeIconView(
2929
modifier: Modifier = Modifier,
3030
icon: ObjectIcon.TypeIcon,
3131
backgroundSize: Dp,
32-
iconWithoutBackgroundMaxSize: Dp = 20.dp,
32+
iconWithoutBackgroundMaxSize: Dp,
33+
imageMultiplier: Float,
3334
backgroundColor: Int = R.color.shape_tertiary
3435
) {
3536
when (icon) {
@@ -71,6 +72,7 @@ fun TypeIconView(
7172
icon = ObjectIcon.Basic.Emoji(unicode = icon.unicode),
7273
backgroundSize = backgroundSize,
7374
iconWithoutBackgroundMaxSize = 120.dp,
75+
imageMultiplier = imageMultiplier
7476
)
7577
} else {
7678
val (imageVector, tint) = getDefaultIconAndTint(icon)

presentation/src/main/java/com/anytypeio/anytype/presentation/editor/EditorViewModel.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6564,9 +6564,10 @@ class EditorViewModel(
65646564
objectTypeKey = objType.uniqueKey
65656565
)
65666566
).fold(
6567-
onFailure = {
6567+
onFailure = { error ->
6568+
sendToast("Error while updating object type: ${error.message}")
65686569
Timber.e(
6569-
it,
6570+
error,
65706571
"Error while updating object type: [${objType.uniqueKey}]"
65716572
)
65726573
},

0 commit comments

Comments
 (0)