|
|
@@ -3,13 +3,17 @@ import SwiftUI
|
|
|
struct PunctuationCheckerView: View {
|
|
|
@StateObject private var viewModel = PunctuationCheckerViewModel()
|
|
|
|
|
|
+ private var showsOutputLayout: Bool {
|
|
|
+ !viewModel.correctedText.isEmpty || viewModel.isChecking
|
|
|
+ }
|
|
|
+
|
|
|
var body: some View {
|
|
|
GeometryReader { proxy in
|
|
|
let dynamicHorizontalPadding = min(max(proxy.size.width * 0.045, AppTheme.contentPadding), 52)
|
|
|
let dynamicBottomPadding = min(max(proxy.size.height * 0.04, 20), 40)
|
|
|
|
|
|
Group {
|
|
|
- if viewModel.correctedText.isEmpty {
|
|
|
+ if !showsOutputLayout {
|
|
|
VStack(alignment: .leading, spacing: 0) {
|
|
|
header
|
|
|
.padding(.bottom, 24)
|
|
|
@@ -107,19 +111,13 @@ struct PunctuationCheckerView: View {
|
|
|
}
|
|
|
|
|
|
private var contentCard: some View {
|
|
|
- VStack(alignment: .leading, spacing: AppTheme.contentCardSpacing) {
|
|
|
+ let compactEditor = showsOutputLayout
|
|
|
+
|
|
|
+ return VStack(alignment: .leading, spacing: AppTheme.contentCardSpacing) {
|
|
|
YourContentHeader()
|
|
|
|
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
|
- ThinCaretTextEditor(
|
|
|
- text: $viewModel.text,
|
|
|
- placeholder: "Type or paste your text here and press the check button...",
|
|
|
- maxWords: PunctuationCheckerViewModel.maxWords,
|
|
|
- onWordLimitReached: viewModel.notifyWordLimitReached
|
|
|
- )
|
|
|
- .font(.system(size: 14))
|
|
|
- .foregroundStyle(AppTheme.textPrimary)
|
|
|
- .frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
+ textEditor
|
|
|
.background(Color.white)
|
|
|
.clipShape(RoundedRectangle(cornerRadius: AppTheme.inputCornerRadius))
|
|
|
.overlay(
|
|
|
@@ -132,7 +130,7 @@ struct PunctuationCheckerView: View {
|
|
|
.foregroundStyle(AppTheme.textMuted)
|
|
|
.frame(maxWidth: .infinity, alignment: .trailing)
|
|
|
}
|
|
|
- .frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
+ .scrollSafeEditorSectionFrame(compact: compactEditor)
|
|
|
|
|
|
HStack(spacing: 8) {
|
|
|
ToolbarButton(title: "Paste Text", iconName: "doc.on.clipboard") {
|
|
|
@@ -151,7 +149,7 @@ struct PunctuationCheckerView: View {
|
|
|
}
|
|
|
}
|
|
|
.inputContentCardPadding()
|
|
|
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
|
|
|
+ .scrollSafeContentCardFrame(compact: compactEditor)
|
|
|
.background(AppTheme.cardBackground)
|
|
|
.clipShape(RoundedRectangle(cornerRadius: AppTheme.cardCornerRadius))
|
|
|
.overlay(
|
|
|
@@ -161,6 +159,18 @@ struct PunctuationCheckerView: View {
|
|
|
.shadow(color: AppTheme.cardShadow, radius: 16, y: 6)
|
|
|
}
|
|
|
|
|
|
+ private var textEditor: some View {
|
|
|
+ ThinCaretTextEditor(
|
|
|
+ text: $viewModel.text,
|
|
|
+ placeholder: "Type or paste your text here and press the check button...",
|
|
|
+ maxWords: PunctuationCheckerViewModel.maxWords,
|
|
|
+ onWordLimitReached: viewModel.notifyWordLimitReached
|
|
|
+ )
|
|
|
+ .font(.system(size: 14))
|
|
|
+ .foregroundStyle(AppTheme.textPrimary)
|
|
|
+ .scrollSafeTextEditorFrame(compact: showsOutputLayout)
|
|
|
+ }
|
|
|
+
|
|
|
private var outputCard: some View {
|
|
|
VStack(alignment: .leading, spacing: 12) {
|
|
|
HStack {
|
|
|
@@ -173,11 +183,21 @@ struct PunctuationCheckerView: View {
|
|
|
ToolbarButton(title: "Copy", iconName: "doc.on.doc") {
|
|
|
viewModel.copyCorrectedText()
|
|
|
}
|
|
|
+ .disabled(viewModel.correctedText.isEmpty)
|
|
|
+ .opacity(viewModel.correctedText.isEmpty ? 0.55 : 1)
|
|
|
}
|
|
|
|
|
|
- Text(viewModel.correctedText)
|
|
|
- .font(.system(size: 14))
|
|
|
- .foregroundStyle(AppTheme.textPrimary)
|
|
|
+ Group {
|
|
|
+ if viewModel.isChecking && viewModel.correctedText.isEmpty {
|
|
|
+ Text("Checking punctuation...")
|
|
|
+ .font(.system(size: 14))
|
|
|
+ .foregroundStyle(AppTheme.textMuted)
|
|
|
+ } else {
|
|
|
+ Text(viewModel.correctedText)
|
|
|
+ .font(.system(size: 14))
|
|
|
+ .foregroundStyle(AppTheme.textPrimary)
|
|
|
+ }
|
|
|
+ }
|
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
.padding(16)
|
|
|
.background(AppTheme.tealLight.opacity(0.35))
|