-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
💄 Implement preview display of text pasted items (#350)
- Loading branch information
1 parent
d48fe4c
commit 081fd0f
Showing
7 changed files
with
156 additions
and
13 deletions.
There are no files selected for viewing
73 changes: 73 additions & 0 deletions
73
composeApp/src/commonMain/kotlin/com/clipevery/ui/base/ClipIcon.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 74 additions & 8 deletions
82
composeApp/src/commonMain/kotlin/com/clipevery/ui/clip/TextPreviewView.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
) | ||
) | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters