8000 Code optimised · lonewolfnadhu/swiftui-ios@974a1d8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 974a1d8

Browse files
committed
Code optimised
1 parent d3f1fdb commit 974a1d8

File tree

5 files changed

+91
-13
lines changed

5 files changed

+91
-13
lines changed

Swift UI/Swift UI.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
A861FB3929ED4351001F2777 /* NetworkManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB3829ED4351001F2777 /* NetworkManager.swift */; };
1919
A861FB3B29ED436E001F2777 /* Results.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB3A29ED436E001F2777 /* Results.swift */; };
2020
A8661F2F29EF26C200B68E72 /* LazyLoadSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8661F2E29EF26C200B68E72 /* LazyLoadSwiftUI.swift */; };
21+
A87D80BF29F0799F00B30666 /* StackViewsSwiftUI.swift in Sources */ = {isa = PBXBuildFile; fileRef = A87D80BE29F0799F00B30666 /* StackViewsSwiftUI.swift */; };
2122
A8D19CE929EC4AF100473ACE /* Swift_UIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8D19CE829EC4AF100473ACE /* Swift_UIApp.swift */; };
2223
A8D19CEB29EC4AF100473ACE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8D19CEA29EC4AF100473ACE /* ContentView.swift */; };
2324
A8D19CED29EC4AF400473ACE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A8D19CEC29EC4AF400473ACE /* Assets.xcassets */; };
@@ -42,6 +43,7 @@
4243
A861FB3829ED4351001F2777 /* NetworkManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NetworkManager.swift; sourceTree = "<group>"; };
4344
A861FB3A29ED436E001F2777 /* Results.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Results.swift; sourceTree = "<group>"; };
4445
A8661F2E29EF26C200B68E72 /* LazyLoadSwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LazyLoadSwiftUI.swift; sourceTree = "<group>"; };
46+
A87D80BE29F0799F00B30666 /* StackViewsSwiftUI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StackViewsSwiftUI.swift; sourceTree = "<group>"; };
4547
A8D19CE529EC4AF000473ACE /* Swift UI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Swift UI.app"; sourceTree = BUILT_PRODUCTS_DIR; };
4648
A8D19CE829EC4AF100473ACE /* Swift_UIApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift_UIApp.swift; sourceTree = "<group>"; };
4749
A8D19CEA29EC4AF100473ACE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -186,6 +188,7 @@
186188
A8E24C4029EC5C8B0061A1C0 /* ToggleButtonSwiftUI.swift */,
187189
A8E24C3E29EC58990061A1C0 /* ShapeSwiftUI.swift */,
188190
A8661F2E29EF26C200B68E72 /* LazyLoadSwiftUI.swift */,
191+
A87D80BE29F0799F00B30666 /* StackViewsSwiftUI.swift */,
189192
);
190193
path = Extras;
191194
sourceTree = "<group>";
@@ -267,6 +270,7 @@
267270
A861FB3529ED4281001F2777 /* DetailView.swift in Sources */,
268271
A861FB3929ED4351001F2777 /* NetworkManager.swift in Sources */,
269272
A8661F2F29EF26C200B68E72 /* LazyLoadSwiftUI.swift in Sources */,
273+
A87D80BF29F0799F00B30666 /* StackViewsSwiftUI.swift in Sources */,
270274
A861FB3B29ED436E001F2777 /* Results.swift in Sources */,
271275
A8D19CEB29EC4AF100473ACE /* ContentView.swift in Sources */,
272276
A861FB2D29ED2F19001F2777 /* Dicee.swift in Sources */,

Swift UI/Swift UI/ContentView.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,16 @@ struct ContentView: View {
133133
.font(.title3)
134134
}
135135

136+
NavigationLink(destination: StackViewsSwiftUI()) {
137+
Text("Stack Views (SwiftUI)")
138+
.frame(minWidth: 0, maxWidth: 250)
139+
.padding()
140+
.foregroundColor(.white)
141+
.background(LinearGradient(gradient: Gradient(colors: [Color.red, Color.blue]), startPoint: .leading, endPoint: .trailing))
142+
.cornerRadius(40)
143+
.font(.title3)
144+
}
145+
136146
Spacer()
137147
}
138148
}

Swift UI/Swift UI/Extras/LazyLoadSwiftUI.swift

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,35 @@ struct LazyLoadSwiftUI: View {
1111
var body: some View {
1212
ScrollView(.vertical){
1313
LazyVStack{
14-
ForEach((0...50), id: \.self) { number in
14+
ForEach((0...5), id: \.self) { number in
15+
Text("Student \(number)")
16+
}
17+
}
18+
}
19+
20+
ScrollView(.vertical){
21+
LazyHStack{
22+
ForEach((0...5), id: \.self) { number in
23+
Text("Student \(number)")
24+
}
25+
}
26+
}
27+
28+
ScrollView(.horizontal){
29+
LazyVStack{
30+
ForEach((0...10), id: \.self) { number in
31+
Text("Student \(number)")
32+
}
33+
}
34+
}
35+
36+
ScrollView(.horizontal){
37+
LazyHStack{
38+
ForEach((0...10), id: \.self) { number in
1539
Text("Student \(number)")
1640
}
1741
}
1842
}
19-
20-
// ScrollView(.horizontal){
21-
// LazyVStack{
22-
// ForEach((0...50), id: \.self) { number in
23-
// Text("Student \(number)")
24-
// }
25-
// }
26-
// }
2743
}
2844
}
2945

Swift UI/Swift UI/Extras/ShapeSwiftUI.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ struct ShapeSwiftUI: View {
32D8 2121
Divider()
2222

2323
Rectangle()
24-
.fill(.orange)
24+
.fill(.red)
2525
.frame(width: 100, height: 100)
2626

2727
Circle()
2828
.fill(.orange)
2929
.frame(width: 100, height: 100)
3030

3131
RoundedRectangle(cornerRadius: 25)
32-
.fill(.orange)
32+
.fill(.green)
3333
.frame(width: 300, height: 100)
3434

3535
Capsule()
36-
.fill(.orange)
36+
.fill(.blue)
3737
.frame(width: 300, height: 100)
3838

3939
Ellipse()
40-
.fill(.orange)
40+
.fill(.purple)
4141
.frame(width: 300, height: 100)
4242

4343
Spacer()
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//
2+
// StackViewsSwiftUI.swift
3+
// Swift UI
4+
//
5+
// Created by Nadir Shah on 19/04/2023.
6+
//
7+
8+
import SwiftUI
9+
10+
struct StackViewsSwiftUI: View {
11+
var body: some View {
12+
ZStack{
13+
VStack{
14+
Spacer()
15+
16+
VStack{
17+
Text("SwiftUI")
18+
Text("in a")
19+
Text("Nutshell")
20+
}
21+
22+
Spacer()
23+
24+
HStack{
25+
Text("SwiftUI")
26+
Text("in a")
27+
Text("Nutshell")
28+
}
29+
30+
Spacer()
31+
32+
ZStack {
33+
Text("SwiftUI in a Nutshell")
34+
RoundedRectangle(cornerRadius: 10)
35+
.frame(width: 100, height: 100)
36+
}
37+
38+
Spacer()
39+
}
40+
}
41+
}
42+
}
43+
44+
struct StackViewsSwiftUI_Previews: PreviewProvider {
45+
static var previews: some View {
46+
StackViewsSwiftUI()
47+
}
48+
}

0 commit comments

Comments
 (0)
0