Skip to content

Commit 65c66a1

Browse files
committed
Start Separating Files
1 parent c4ddd4e commit 65c66a1

File tree

7 files changed

+200
-141
lines changed

7 files changed

+200
-141
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
//
2+
// SnowfallView.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
struct SnowfallView: View {
11+
@State private var snowflakes = [Snowflake]()
12+
private let timer = Timer.publish(every: 0.05, on: .main, in: .common).autoconnect()
13+
14+
var body: some View {
15+
GeometryReader { geometry in
16+
ZStack {
17+
ForEach(snowflakes) { snowflake in
18+
Circle()
19+
.fill(Color.white)
20+
.frame(width: snowflake.size, height: snowflake.size)
21+
.position(x: snowflake.x, y: snowflake.y)
22+
}
23+
}
24+
.onAppear {
25+
for _ in 0..<100 {
26+
let snowflake = Snowflake(
27+
id: UUID(),
28+
x: CGFloat.random(in: 0...geometry.size.width),
29+
y: CGFloat.random(in: -geometry.size.height...0),
30+
size: CGFloat.random(in: 2...6),
31+
speed: CGFloat.random(in: 1...3)
32+
)
33+
snowflakes.append(snowflake)
34+
}
35+
}
36+
.onReceive(timer) { _ in
37+
for index in snowflakes.indices {
38+
snowflakes[index].y += snowflakes[index].speed
39+
if snowflakes[index].y > geometry.size.height {
40+
snowflakes[index].y = -snowflakes[index].size
41+
snowflakes[index].x = CGFloat.random(in: 0...geometry.size.width)
42+
}
43+
}
44+
}
45+
}
46+
}
47+
}

Sources/SwiftNEW/Bundle+Ext.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
//
2+
// Bundle+Ext.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
// MARK: - For App Icon
11+
extension Bundle {
12+
var iconFileName: String? {
13+
guard let icons = infoDictionary?["CFBundleIcons"] as? [String: Any],
14+
let primaryIcon = icons["CFBundlePrimaryIcon"] as? [String: Any],
15+
let iconFiles = primaryIcon["CFBundleIconFiles"] as? [String],
16+
let iconFileName = iconFiles.last
17+
else { return nil }
18+
return iconFileName
19+
}
20+
}

Sources/SwiftNEW/Model.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// Vmodel.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
// MARK: - Model
11+
public struct Vmodel: Codable, Hashable {
12+
var version: String
13+
var subVersion: String?
14+
var new: [Model]
15+
}
16+
public struct Model: Codable, Hashable {
17+
var icon: String
18+
var title: String
19+
var subtitle: String
20+
var body: String
21+
}
22+
struct Snowflake: Identifiable {
23+
let id: UUID
24+
var x: CGFloat
25+
var y: CGFloat
26+
var size: CGFloat
27+
var speed: CGFloat
28+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//
2+
// AppIconView.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
#if os(iOS)
8+
import SwiftUI
9+
10+
public struct AppIconView: View {
11+
public var body: some View {
12+
Bundle.main.iconFileName
13+
.flatMap {
14+
UIImage(named: $0)
15+
}
16+
.map {
17+
Image(uiImage: $0)
18+
.resizable()
19+
.frame(width: 65, height: 65)
20+
.overlay(
21+
RoundedRectangle(cornerRadius: 19, style: .continuous)
22+
.stroke(.gray, lineWidth: 1)
23+
)
24+
}
25+
.clipShape(RoundedRectangle(cornerRadius: 19, style: .continuous))
26+
}
27+
}
28+
#endif
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//
2+
// MeshView.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
struct MeshView: View {
11+
@Binding var color: Color
12+
var body: some View {
13+
if #available(iOS 18.0, macOS 15.0, visionOS 2.0, *) {
14+
MeshGradient(width: 3, height: 3, points: [
15+
.init(0, 0), .init(0.5, 0), .init(1, 0),
16+
.init(0, 0.5), .init(0.5, 0.5), .init(1, 0.5),
17+
.init(0, 1), .init(0.5, 1), .init(1, 1)
18+
], colors: [
19+
Color(.clear), Color(.clear), Color(.clear),
20+
color.opacity(0.1), color.opacity(0.1), color.opacity(0.2),
21+
color.opacity(0.5), color.opacity(0.6), color.opacity(0.7)
22+
])
23+
.ignoresSafeArea(.all)
24+
.overlay(
25+
NoiseView(size: 100000)
26+
)
27+
} else {
28+
// Fallback on earlier versions
29+
LinearGradient(colors: [Color.accentColor.opacity(0.5), Color(.clear)], startPoint: .topLeading, endPoint: .bottomTrailing)
30+
.ignoresSafeArea(.all)
31+
}
32+
}
33+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// NoiseView.swift
3+
// SwiftNEW
4+
//
5+
// Created by Ming on 7/1/2025.
6+
//
7+
8+
import SwiftUI
9+
10+
struct NoiseView: View {
11+
let size: Int
12+
13+
var body: some View {
14+
Canvas { context, size in
15+
for _ in 0..<self.size {
16+
let x = Double.random(in: 0..<Double(size.width))
17+
let y = Double.random(in: 0..<Double(size.height))
18+
#if os(iOS)
19+
context.fill(Ellipse().path(in: CGRect(x: x, y: y, width: 1, height: 1)), with: .color(Color(.systemBackground).opacity(0.1)))
20+
#elseif os(macOS)
21+
context.fill(Ellipse().path(in: CGRect(x: x, y: y, width: 1, height: 1)), with: .color(Color(NSColor.windowBackgroundColor).opacity(0.1)))
22+
#endif
23+
}
24+
}
25+
.opacity(0.5)
26+
}
27+
}

0 commit comments

Comments
 (0)