- Added pull-to-refresh to ResidencesListView with force refresh support - Added pull-to-refresh to AllTasksView with rotating refresh button - Added pull-to-refresh to ContractorsListView with force refresh - Added pull-to-refresh to DocumentsTabContent and WarrantiesTabContent - Improved loading state checks to prevent empty list flash during initial load - Added refresh button to AllTasksView toolbar with clockwise rotation animation - Improved UX by disabling refresh button while loading is in progress 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
97 lines
3.9 KiB
Swift
97 lines
3.9 KiB
Swift
import SwiftUI
|
|
import ComposeApp
|
|
|
|
struct HomeScreenView: View {
|
|
@StateObject private var viewModel = ResidenceViewModel()
|
|
@StateObject private var loginViewModel = LoginViewModel()
|
|
|
|
var body: some View {
|
|
NavigationView {
|
|
ZStack {
|
|
AppColors.background
|
|
.ignoresSafeArea()
|
|
|
|
if viewModel.isLoading {
|
|
VStack(spacing: AppSpacing.lg) {
|
|
ProgressView()
|
|
.scaleEffect(1.2)
|
|
Text("Loading...")
|
|
.font(AppTypography.bodyMedium)
|
|
.foregroundColor(AppColors.textSecondary)
|
|
}
|
|
} else {
|
|
ScrollView(showsIndicators: false) {
|
|
VStack(spacing: AppSpacing.xl) {
|
|
// Greeting Header
|
|
VStack(alignment: .leading, spacing: AppSpacing.xs) {
|
|
Text("Hello!")
|
|
.font(AppTypography.headlineLarge)
|
|
.fontWeight(.bold)
|
|
.foregroundColor(AppColors.textPrimary)
|
|
|
|
Text("Welcome to MyCrib")
|
|
.font(AppTypography.bodyLarge)
|
|
.foregroundColor(AppColors.textSecondary)
|
|
}
|
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
.padding(.horizontal, AppSpacing.md)
|
|
.padding(.top, AppSpacing.md)
|
|
|
|
// Overview Card
|
|
if let summary = viewModel.residenceSummary {
|
|
OverviewCard(summary: summary.summary)
|
|
.transition(.scale.combined(with: .opacity))
|
|
}
|
|
|
|
// Navigation Cards
|
|
VStack(spacing: AppSpacing.md) {
|
|
NavigationLink(destination: ResidencesListView()) {
|
|
HomeNavigationCard(
|
|
icon: "house.fill",
|
|
title: "Residences",
|
|
subtitle: "Manage your properties"
|
|
)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
|
|
NavigationLink(destination: AllTasksView()) {
|
|
HomeNavigationCard(
|
|
icon: "checkmark.circle.fill",
|
|
title: "Tasks",
|
|
subtitle: "View and manage all tasks"
|
|
)
|
|
}
|
|
.buttonStyle(PlainButtonStyle())
|
|
}
|
|
.padding(.horizontal, AppSpacing.md)
|
|
}
|
|
.padding(.vertical, AppSpacing.md)
|
|
}
|
|
}
|
|
}
|
|
.navigationTitle("MyCrib")
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
Button(action: {
|
|
loginViewModel.logout()
|
|
}) {
|
|
HStack(spacing: AppSpacing.xs) {
|
|
Image(systemName: "rectangle.portrait.and.arrow.right")
|
|
.font(.system(size: 18, weight: .semibold))
|
|
}
|
|
.foregroundColor(AppColors.error)
|
|
}
|
|
}
|
|
}
|
|
.onAppear {
|
|
viewModel.loadResidenceSummary()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview {
|
|
HomeScreenView()
|
|
}
|