Repository navigation
feature: deploy v1.0.18 to main branch #50
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
Changes from all commits
07308ef
6b19347
b152529
dd31008
6478085
d735268
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,27 @@ struct StatusBadge: View { | |
|
|
||
| @Environment(\.voticeTheme) private var theme | ||
|
|
||
| private var statusColor: Color { | ||
| let status: SuggestionStatusEntity | ||
| let progress: Int? | ||
| let useLiquidGlass: Bool | ||
|
|
||
| // MARK: - View | ||
|
|
||
| var body: some View { | ||
| if status == .inProgress, let progress { | ||
| inProgressTagView(with: progress) | ||
| } else { | ||
| defaultTagView | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // MARK: - Private | ||
|
|
||
| private extension StatusBadge { | ||
| // MARK: - Properties | ||
|
|
||
| var statusColor: Color { | ||
| switch status { | ||
| case .accepted: | ||
| return theme.colors.accepted | ||
|
|
@@ -29,7 +49,8 @@ struct StatusBadge: View { | |
| return theme.colors.rejected | ||
| } | ||
| } | ||
| private var statusText: String { | ||
|
|
||
| var statusText: String { | ||
| let texts = TextManager.shared.texts | ||
|
|
||
| switch status { | ||
|
|
@@ -40,6 +61,10 @@ struct StatusBadge: View { | |
| case .completed: | ||
| return texts.completed | ||
| case .inProgress: | ||
| if let progress { | ||
| return "\(texts.inProgress) \(progress)%" | ||
| } | ||
|
|
||
| return texts.inProgress | ||
| case .pending: | ||
| return texts.pending | ||
|
|
@@ -48,21 +73,47 @@ struct StatusBadge: View { | |
| } | ||
| } | ||
|
|
||
| let status: SuggestionStatusEntity | ||
| let useLiquidGlass: Bool | ||
|
|
||
| // MARK: - View | ||
|
|
||
| var body: some View { | ||
| var defaultTagView: some View { | ||
| Text(statusText) | ||
| .font(theme.typography.caption) | ||
| .foregroundColor(.white) | ||
| .padding(.horizontal, theme.spacing.sm) | ||
| .padding(.vertical, theme.spacing.xs) | ||
| .padding(.horizontal, theme.spacing.sm) | ||
| .adaptiveGlassBackground( | ||
| useLiquidGlass: useLiquidGlass, | ||
| cornerRadius: theme.cornerRadius.sm, | ||
| fillColor: statusColor | ||
| ) | ||
| } | ||
|
|
||
| // MARK: - Functions | ||
|
|
||
| func inProgressTagView(with progress: Int) -> some View { | ||
| let fullText = statusText | ||
| let splitIndex = Int(Double(fullText.count) * Double(progress) / 100.0) + 1 | ||
| let completedPart = String(fullText.prefix(splitIndex)) | ||
| let remainingPart = String(fullText.dropFirst(splitIndex)) | ||
|
Comment on lines
+91
to
+95
|
||
|
|
||
| return Text("\(Text(completedPart).foregroundStyle(.white))\(Text(remainingPart).foregroundStyle(statusColor))") | ||
| .font(theme.typography.caption) | ||
| .padding(.vertical, theme.spacing.xs) | ||
| .padding(.horizontal, theme.spacing.sm) | ||
| .background { | ||
| GeometryReader { geometry in | ||
| ZStack(alignment: .leading) { | ||
| RoundedRectangle(cornerRadius: theme.cornerRadius.sm) | ||
| .fill(statusColor.opacity(0.3)) | ||
| RoundedRectangle(cornerRadius: theme.cornerRadius.sm) | ||
| .fill( | ||
| LinearGradient( | ||
| gradient: Gradient(colors: [statusColor, statusColor.opacity(0.7)]), | ||
| startPoint: .leading, | ||
| endPoint: .trailing | ||
| ) | ||
| ) | ||
| .frame(width: geometry.size.width * CGFloat(progress) / 100.0) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -66,7 +66,11 @@ extension SuggestionDetailView { | |||
| .foregroundColor(theme.colors.onSurface) | ||||
| .multilineTextAlignment(.leading) | ||||
| Spacer() | ||||
| StatusBadge(status: currentSuggestion.status ?? .pending, useLiquidGlass: false) | ||||
| StatusBadge( | ||||
| status: currentSuggestion.status ?? .pending, | ||||
| progress: currentSuggestion.progress, | ||||
| useLiquidGlass: false) | ||||
|
|
||||
|
||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
+ 1in thesplitIndexcalculation causes at least one character to always be displayed as completed, even whenprogressis 0. This means at 0% progress, the first character of the text will be shown in white (completed color), which may not be the intended behavior.Consider removing the
+ 1to make the progress indicator more accurate:Additionally, consider adding input validation to ensure
progressis within the expected 0-100 range.