Skip to content

Commit

Permalink
Feature/Animate list on project localize (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
yllfejziu authored Nov 20, 2023
1 parent dcf6911 commit fc2cd63
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ struct ProjectFormView: View {
swiftCodeFormSection()
iOSInfoFormSection()
}
.navigationTitle(viewModel.project.title)
.navigationSubtitle(viewModel.project.lastLocalizedAt.map { Lingua.ProjectForm.lastLocalizedSubtitle($0.formatted) } ?? "")
.toolbar {
ToolbarItem(placement: .cancellationAction) {
VStack(alignment: .leading) {
Text(viewModel.project.title)
.font(.headline)
Text(viewModel.project.lastLocalizedAt.map { Lingua.ProjectForm.lastLocalizedSubtitle($0.formatted) } ?? "")
.font(.subheadline)
}
}
ToolbarItem(placement: .primaryAction) {
localizeButton()
}
Expand Down
29 changes: 24 additions & 5 deletions Lingua-App/Lingua/Lingua/Scenes/Projects/ProjectsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,20 @@ import SwiftUI

struct ProjectsView: View {
@EnvironmentObject private var viewModel: ProjectsViewModel

@State private var columnVisibility = NavigationSplitViewVisibility.automatic

var body: some View {
NavigationSplitView {
NavigationSplitView(columnVisibility: $columnVisibility) {
VStack {
HStack {
Image(systemName: "folder")
Text("Projects")
}
Spacer()
}
} content: {
CustomSearchBar(searchTerm: $viewModel.searchTerm)

List(viewModel.filteredProjects, selection: $viewModel.selectedProjectId) { project in
ProjectItemView(project: project)
.swipeActions(edge: .trailing) {
Expand All @@ -25,7 +34,7 @@ struct ProjectsView: View {
deletionButton(for: project)
}
}
.navigationSplitViewColumnWidth(min: 250, ideal: 250, max: 600)
.navigationSplitViewColumnWidth(min: 340, ideal: 340, max: 500)
.listStyle(DefaultListStyle())
.toolbar {
Button(action: {
Expand All @@ -39,11 +48,21 @@ struct ProjectsView: View {
} detail: {
if let project = viewModel.selectedProject {
projectFormView(for: project)
.toolbar {
Spacer()
}
} else {
Text(Lingua.Projects.placeholder)
.toolbar {
Spacer()
}
}
}
.onAppear { viewModel.selectFirstProject() }
.scrollContentBackground(.hidden)
.onAppear {
viewModel.selectFirstProject()
columnVisibility = .doubleColumn
}
.alert(isPresented: $viewModel.showDeleteAlert) { deletionAlert() }
.overlay(ProgressOverlay(
isProgressing: $viewModel.isLocalizing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,10 @@ extension ProjectsViewModel {
@MainActor
func updateSyncDate(for project: Project) {
if let index = projects.firstIndex(where: { $0.id == project.id }) {
var updatedProject = project
updatedProject.lastLocalizedAt = Date()
projects[index] = updatedProject

updateSelectedProject(updatedProject)
withAnimation {
projects[index].lastLocalizedAt = Date()
projects.insert(projects.remove(at: index), at: 0)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ struct HUDOverlay: View {
var body: some View {
ZStack {
Color(NSColor.windowBackgroundColor)
.opacity(0.8)
.opacity(0.5)
.onTapGesture { dismiss() }

VStack(spacing: 10) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,14 @@ struct ProgressOverlay: View {
var body: some View {
if isProgressing {
ZStack {
Color(NSColor.windowBackgroundColor).opacity(0.8)
Color(NSColor.windowBackgroundColor).opacity(0.5)
ProgressView(text)
.padding()
.background(Color(NSColor.windowBackgroundColor))
.cornerRadius(10)
.shadow(radius: 10)
.padding(40)
}
.transition(.opacity)
}
}
}

0 comments on commit fc2cd63

Please sign in to comment.