Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>DesignRemakes.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
116 changes: 52 additions & 64 deletions DesignRemakes/Calendar/CalendarView.swift
Original file line number Diff line number Diff line change
@@ -1,107 +1,85 @@
//
// CalendarView.swift
// DesignRemakes
//
// Created by Florian Schweizer on 22.02.22.
// Design from https://dribbble.com/shots/15571949/attachments/7356584?mode=media
//

import SwiftUI

struct CalendarView: View {
var body: some View {
VStack(alignment: .leading, spacing: 32) {
topBar

monthBar
.padding(.horizontal)

HStack(spacing: 0) {
DayBox(date: 12, day: "Wed", isSelected: true)
Spacer()
DayBox(date: 13, day: "Thu", isSelected: false)
Spacer()
DayBox(date: 14, day: "Fri", isSelected: false)
Spacer()
DayBox(date: 15, day: "Sat", isSelected: false)

// Horizontal Scroll for Days
ScrollView(.horizontal, showsIndicators: false) {
HStack(spacing: 16) {
ForEach(1...31, id: \.self) { day in
let isSelected = day == 12 // Replace with dynamic selection logic
DayBox(date: day, day: dayOfWeek(for: day), isSelected: isSelected)
}
}
.padding(.horizontal)
}
.padding(.horizontal)


Text("Ongoing")
.font(.title)
.fontWeight(.bold)

ScrollView {
HStack {

// Vertical Scroll for Times
ScrollView(.vertical, showsIndicators: false) {
HStack(alignment: .top) {
// Time labels
VStack(alignment: .trailing) {
ForEach(7...12, id: \.self) { hour in
Text("\(hour) AM")
ForEach(0..<25, id: \.self) { hour in
Text("\(hour % 12 == 0 ? 12 : hour % 12) \(hour < 12 ? "AM" : "PM")")
.frame(height: 64)
}
}
.foregroundColor(.secondary)

VStack {
CalendarEvent()

HStack(spacing: 0) {
Circle()
.fill(.red)
.frame(width: 8, height: 8)
.padding(4)
.background(Circle().fill(.white))
.clipped()
.shadow(radius: 3)

VStack {
Divider()
.frame(height: 2)
.background(.red)
}

// Events
VStack(spacing: 16) {
ForEach(0..<5, id: \.self) { _ in
CalendarEvent()
}

CalendarEvent()
CalendarEvent()
}
}
}
}
.padding(.horizontal)
.background(Color.blue.opacity(0.05).ignoresSafeArea())
}

private var monthBar: some View {
HStack {
Button { } label: {
HStack {
Image(systemName: "arrow.left")
.foregroundColor(.gray)

Text("Sep")
.foregroundColor(.primary)
}
}

Spacer()

Text("October")
.font(.title)
.fontWeight(.semibold)

Spacer()

Button { } label: {
HStack {
Text("Nov")
.foregroundColor(.primary)

Image(systemName: "arrow.right")
.foregroundColor(.gray)
}
}
}
}

private var topBar: some View {
HStack {
Button { } label: {
Expand All @@ -114,37 +92,47 @@ struct CalendarView: View {
}
.foregroundColor(.primary)
}

Spacer()

Image(systemName: "person.circle")
.resizable()
.scaledToFit()
.frame(width: 40, height: 40)
}
}

private func dayOfWeek(for day: Int) -> String {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy-MM-dd"
let calendar = Calendar.current
let dateComponents = DateComponents(year: 2024, month: 10, day: day)
let date = calendar.date(from: dateComponents) ?? Date()
formatter.dateFormat = "E"
return formatter.string(from: date)
}
}

struct CalendarEvent: View {
var body: some View {
VStack(alignment: .leading) {
Text("Mobile App Design")
.font(.headline)
Text("Mike and anita")

Text("Mike and Anita")
.font(.subheadline)

Spacer()

HStack {
Image(systemName: "person.circle.fill")
.font(.title)
Image(systemName: "person.circle.fill")
.font(.title)
.offset(x: -16)

Spacer()

Text("9.00 AM - 10.00 AM")
.font(.caption)
}
Expand All @@ -165,13 +153,13 @@ struct DayBox: View {
let date: Int
let day: String
let isSelected: Bool

var body: some View {
VStack {
Text("\(date)")
.font(.title)
.fontWeight(.semibold)

Text(day)
.fontWeight(.light)
}
Expand Down