Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💄 Implement preview display of text pasted items #350

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions composeApp/src/commonMain/kotlin/com/clipevery/ui/base/ClipIcon.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
package com.clipevery.ui.base

import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.PathFillType.Companion.NonZero
import androidx.compose.ui.graphics.SolidColor
import androidx.compose.ui.graphics.StrokeCap.Companion.Butt
import androidx.compose.ui.graphics.StrokeJoin.Companion.Miter
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.graphics.vector.path
import androidx.compose.ui.unit.dp

@Composable
fun feed(): ImageVector {
return remember {
ImageVector.Builder(
name = "Feed", defaultWidth = 24.0.dp, defaultHeight = 24.0.dp,
viewportWidth = 960.0f, viewportHeight = 960.0f
).apply {
path(fill = SolidColor(Color(0xFF000000)), stroke = null, strokeLineWidth = 0.0f,
strokeLineCap = Butt, strokeLineJoin = Miter, strokeLineMiter = 4.0f,
pathFillType = NonZero) {
moveTo(200.0f, 840.0f)
quadToRelative(-33.0f, 0.0f, -56.5f, -23.5f)
reflectiveQuadTo(120.0f, 760.0f)
verticalLineToRelative(-560.0f)
quadToRelative(0.0f, -33.0f, 23.5f, -56.5f)
reflectiveQuadTo(200.0f, 120.0f)
horizontalLineToRelative(440.0f)
lineToRelative(200.0f, 200.0f)
verticalLineToRelative(440.0f)
quadToRelative(0.0f, 33.0f, -23.5f, 56.5f)
reflectiveQuadTo(760.0f, 840.0f)
lineTo(200.0f, 840.0f)
close()
moveTo(200.0f, 760.0f)
horizontalLineToRelative(560.0f)
verticalLineToRelative(-400.0f)
lineTo(600.0f, 360.0f)
verticalLineToRelative(-160.0f)
lineTo(200.0f, 200.0f)
verticalLineToRelative(560.0f)
close()
moveTo(280.0f, 680.0f)
horizontalLineToRelative(400.0f)
verticalLineToRelative(-80.0f)
lineTo(280.0f, 600.0f)
verticalLineToRelative(80.0f)
close()
moveTo(280.0f, 360.0f)
horizontalLineToRelative(200.0f)
verticalLineToRelative(-80.0f)
lineTo(280.0f, 280.0f)
verticalLineToRelative(80.0f)
close()
moveTo(280.0f, 520.0f)
horizontalLineToRelative(400.0f)
verticalLineToRelative(-80.0f)
lineTo(280.0f, 440.0f)
verticalLineToRelative(80.0f)
close()
moveTo(200.0f, 200.0f)
verticalLineToRelative(160.0f)
verticalLineToRelative(-160.0f)
verticalLineToRelative(560.0f)
verticalLineToRelative(-560.0f)
close()
}
}
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fun ClipPreviewItemView(clipData: ClipData, clipContent: @Composable ClipAppearI

Row(modifier = Modifier
.fillMaxWidth()
.height(64.dp)
.height(150.dp)
.onPointerEvent(
eventType = PointerEventType.Enter,
onEvent = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,34 +1,100 @@
package com.clipevery.ui.clip

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.material.Icon
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.clipevery.LocalKoinApplication
import com.clipevery.clip.item.ClipText
import com.clipevery.dao.clip.ClipData
import com.clipevery.i18n.GlobalCopywriter
import com.clipevery.ui.base.feed

fun getTitle(clipText: ClipText): String {
return clipText.text
val parts = clipText.text.split("\n", limit = 2)
println(parts[0])
return parts[0]
}

@Composable
fun TextPreviewView(clipData: ClipData) {
val current = LocalKoinApplication.current
val copywriter = current.koin.get<GlobalCopywriter>()

clipData.getClipItem(ClipText::class)?.let {
Column() {
Text(text = getTitle(it),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
Column(
modifier = Modifier.fillMaxWidth()
.padding(8.dp)
) {
Row(
modifier = Modifier.fillMaxWidth().padding(bottom = 10.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Text(
modifier = Modifier.weight(1f),
text = getTitle(it),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
fontFamily = FontFamily.SansSerif,
style = TextStyle(
fontWeight = FontWeight.Bold,
color = MaterialTheme.colors.onBackground,
fontSize = 17.sp
)
)

Row(
modifier = Modifier.wrapContentWidth(),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically
) {
Icon(
feed(),
contentDescription = "Text",
modifier = Modifier.padding(3.dp).size(14.dp),
tint = MaterialTheme.colors.onBackground
)

Text(
text = copywriter.getText("Text"),
fontFamily = FontFamily.SansSerif,
style = TextStyle(
fontWeight = FontWeight.Light,
color = MaterialTheme.colors.onBackground,
fontSize = 8.sp
)
)
}
}


Text(
modifier = Modifier.weight(1f),
text = it.text,
fontFamily = FontFamily.SansSerif,
style = TextStyle(
fontWeight = FontWeight.Bold,
fontWeight = FontWeight.Normal,
color = MaterialTheme.colors.onBackground,
fontSize = 17.sp
fontSize = 14.sp
)
)
}
}

}
}
3 changes: 2 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Sync_Control=Sync Control
Base_Info=Base Info
Allow_Send_to_this_device=Allow Send to this device
Allow_Receive_from_this_device=Allow Receive from this device
Remove_Device=Remove Device
Remove_Device=Remove Device
Text=Text
3 changes: 2 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/es.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Sync_Control=Control de sincronización
Base_Info=Información básica
Allow_Send_to_this_device=Permitir enviar a este dispositivo
Allow_Receive_from_this_device=Permitir recibir de este dispositivo
Remove_Device=Eliminar dispositivo
Remove_Device=Eliminar dispositivo
Text=Texto
3 changes: 2 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/jp.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Sync_Control=同期制御
Base_Info=基本情報
Allow_Send_to_this_device=このデバイスに送信を許可する
Allow_Receive_from_this_device=このデバイスからの受信を許可する
Remove_Device=デバイスを削除
Remove_Device=デバイスを削除
Text=テキスト
3 changes: 2 additions & 1 deletion composeApp/src/desktopMain/resources/i18n/zh.properties
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ Sync_Control=同步控制
Base_Info=基础信息
Allow_Send_to_this_device=允许发送到此设备
Allow_Receive_from_this_device=允许从此设备接收
Remove_Device=移除设备
Remove_Device=移除设备
Text=文本
Loading