mirror of
https://github.com/wahyd4/image-flow.git
synced 2026-08-09 05:05:59 +10:00
Clock position
This commit is contained in:
@@ -91,7 +91,7 @@ struct SlideshowView: View {
|
||||
}
|
||||
|
||||
private func getClockPosition(in size: CGSize) -> CGPoint {
|
||||
let padding: CGFloat = 50
|
||||
let padding: CGFloat = 140
|
||||
|
||||
switch clockPosition {
|
||||
case .topCenter:
|
||||
@@ -165,31 +165,18 @@ struct DigitalClockView: View {
|
||||
|
||||
private var timeFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "HH:mm:ss"
|
||||
return formatter
|
||||
}
|
||||
|
||||
private var dateFormatter: DateFormatter {
|
||||
let formatter = DateFormatter()
|
||||
formatter.dateFormat = "EEEE, MMMM d, yyyy"
|
||||
formatter.dateFormat = "HH:mm"
|
||||
return formatter
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(spacing: 4) {
|
||||
Text(timeFormatter.string(from: currentTime))
|
||||
.font(.system(size: 60, weight: .bold, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
.shadow(color: .black.opacity(0.5), radius: 2, x: 0, y: 1)
|
||||
|
||||
Text(dateFormatter.string(from: currentTime))
|
||||
.font(.system(size: 20, weight: .medium, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
.shadow(color: .black.opacity(0.5), radius: 2, x: 0, y: 1)
|
||||
}
|
||||
.padding()
|
||||
.background(Color.black.opacity(0.3))
|
||||
.cornerRadius(16)
|
||||
Text(timeFormatter.string(from: currentTime))
|
||||
.font(.system(size: 52, weight: .bold, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
.shadow(color: .black.opacity(0.5), radius: 2, x: 0, y: 1)
|
||||
.padding(12)
|
||||
.background(Color.black.opacity(0.3))
|
||||
.cornerRadius(12)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,51 +209,51 @@ struct AnalogClockView: View {
|
||||
// Clock face
|
||||
Circle()
|
||||
.fill(Color.black.opacity(0.5))
|
||||
.frame(width: 200, height: 200)
|
||||
.frame(width: 150, height: 150)
|
||||
.overlay(
|
||||
Circle()
|
||||
.stroke(Color.white, lineWidth: 4)
|
||||
.stroke(Color.white, lineWidth: 3)
|
||||
)
|
||||
|
||||
// Hour markers
|
||||
ForEach(0..<12) { hour in
|
||||
Rectangle()
|
||||
.fill(Color.white)
|
||||
.frame(width: 4, height: hour % 3 == 0 ? 15 : 8)
|
||||
.offset(y: -85)
|
||||
.frame(width: 3, height: hour % 3 == 0 ? 12 : 6)
|
||||
.offset(y: -65)
|
||||
.rotationEffect(.degrees(Double(hour) * 30))
|
||||
}
|
||||
|
||||
// Hour hand
|
||||
Rectangle()
|
||||
.fill(Color.white)
|
||||
.frame(width: 4, height: 60)
|
||||
.cornerRadius(2)
|
||||
.offset(y: -30)
|
||||
.frame(width: 3, height: 45)
|
||||
.cornerRadius(1.5)
|
||||
.offset(y: -22.5)
|
||||
.rotationEffect(.degrees(Double(hour) * 360))
|
||||
|
||||
// Minute hand
|
||||
Rectangle()
|
||||
.fill(Color.white)
|
||||
.frame(width: 3, height: 80)
|
||||
.cornerRadius(1.5)
|
||||
.offset(y: -40)
|
||||
.frame(width: 2, height: 60)
|
||||
.cornerRadius(1)
|
||||
.offset(y: -30)
|
||||
.rotationEffect(.degrees(Double(minute) * 360))
|
||||
|
||||
// Second hand
|
||||
Rectangle()
|
||||
.fill(Color.red)
|
||||
.frame(width: 1, height: 90)
|
||||
.frame(width: 1, height: 70)
|
||||
.cornerRadius(0.5)
|
||||
.offset(y: -45)
|
||||
.offset(y: -35)
|
||||
.rotationEffect(.degrees(Double(second) * 360))
|
||||
|
||||
// Center cap
|
||||
Circle()
|
||||
.fill(Color.white)
|
||||
.frame(width: 12, height: 12)
|
||||
.frame(width: 8, height: 8)
|
||||
}
|
||||
.frame(width: 220, height: 220)
|
||||
.frame(width: 160, height: 160)
|
||||
.shadow(color: .black.opacity(0.5), radius: 5, x: 0, y: 2)
|
||||
}
|
||||
}
|
||||
@@ -282,7 +269,7 @@ struct MinimalClockView: View {
|
||||
|
||||
var body: some View {
|
||||
Text(timeFormatter.string(from: currentTime))
|
||||
.font(.system(size: 80, weight: .thin, design: .rounded))
|
||||
.font(.system(size: 52, weight: .thin, design: .rounded))
|
||||
.foregroundColor(.white)
|
||||
.shadow(color: .black.opacity(0.5), radius: 2, x: 0, y: 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user