mirror of
https://github.com/carey314/mio-plugin-clipper.git
synced 2026-08-10 07:44:32 +00:00
50 lines
1.6 KiB
Swift
50 lines
1.6 KiB
Swift
|
|
//
|
||
|
|
// SourcePreview.swift
|
||
|
|
// 划词侠 plugin
|
||
|
|
//
|
||
|
|
// Compact card showing the current source text — 3 lines, soft border,
|
||
|
|
// monospace fallback for long URLs/code.
|
||
|
|
//
|
||
|
|
|
||
|
|
import SwiftUI
|
||
|
|
|
||
|
|
struct SourcePreview: View {
|
||
|
|
let text: String
|
||
|
|
|
||
|
|
var body: some View {
|
||
|
|
VStack(alignment: .leading, spacing: 6) {
|
||
|
|
HStack(spacing: 6) {
|
||
|
|
Image(systemName: "text.alignleft")
|
||
|
|
.font(.system(size: 10, weight: .semibold))
|
||
|
|
.foregroundColor(ClipperTheme.fg45)
|
||
|
|
Text("待处理文本")
|
||
|
|
.font(.system(size: 10.5, weight: .semibold))
|
||
|
|
.foregroundColor(ClipperTheme.fg45)
|
||
|
|
Spacer()
|
||
|
|
Text("\(text.count) 字")
|
||
|
|
.font(.system(size: 10, weight: .medium))
|
||
|
|
.foregroundColor(ClipperTheme.fg40)
|
||
|
|
.monospacedDigit()
|
||
|
|
}
|
||
|
|
Text(text)
|
||
|
|
.font(.system(size: 12))
|
||
|
|
.foregroundColor(ClipperTheme.fg85)
|
||
|
|
.lineLimit(3)
|
||
|
|
.truncationMode(.tail)
|
||
|
|
.multilineTextAlignment(.leading)
|
||
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||
|
|
}
|
||
|
|
.padding(.horizontal, 12)
|
||
|
|
.padding(.vertical, 10)
|
||
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
||
|
|
.background(
|
||
|
|
RoundedRectangle(cornerRadius: 12)
|
||
|
|
.fill(ClipperTheme.overlay04)
|
||
|
|
.overlay(
|
||
|
|
RoundedRectangle(cornerRadius: 12)
|
||
|
|
.stroke(ClipperTheme.overlay08, lineWidth: 0.5)
|
||
|
|
)
|
||
|
|
)
|
||
|
|
}
|
||
|
|
}
|