8000 Dicee app added · lonewolfnadhu/swiftui-ios@d46bf75 · GitHub
[go: up one dir, main page]

Skip to content

Commit d46bf75

Browse files
committed
Dicee app added
1 parent 87ed8e5 commit d46bf75

File tree

5 files changed

+119
-9
lines changed

5 files changed

+119
-9
lines changed

Swift UI/.DS_Store

0 Bytes
Binary file not shown.

Swift UI/Swift UI.xcodeproj/project.pbxproj

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
A861FB2129ED27D6001F2777 /* NadirCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB2029ED27D6001F2777 /* NadirCard.swift */; };
1111
A861FB2529ED2913001F2777 /* InfoView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB2429ED2913001F2777 /* InfoView.swift */; };
1212
A861FB2B29ED2D1C001F2777 /* Pacifico-Regular.ttf in Resources */ = {isa = PBXBuildFile; fileRef = A861FB2A29ED2D1C001F2777 /* Pacifico-Regular.ttf */; };
13+
A861FB2D29ED2F19001F2777 /* Dicee.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB2C29ED2F19001F2777 /* Dicee.swift */; };
14+
A861FB3029ED3131001F2777 /* DiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A861FB2F29ED3131001F2777 /* DiceView.swift */; };
1315
A8D19CE929EC4AF100473ACE /* Swift_UIApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8D19CE829EC4AF100473ACE /* Swift_UIApp.swift */; };
1416
A8D19CEB29EC4AF100473ACE /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8D19CEA29EC4AF100473ACE /* ContentView.swift */; };
1517
A8D19CED29EC4AF400473ACE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A8D19CEC29EC4AF400473ACE /* Assets.xcassets */; };
@@ -26,6 +28,8 @@
2628
A861FB2029ED27D6001F2777 /* NadirCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NadirCard.swift; sourceTree = "<group>"; };
2729
A861FB2429ED2913001F2777 /* InfoView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InfoView.swift; sourceTree = "<group>"; };
2830
A861FB2A29ED2D1C001F2777 /* Pacifico-Regular.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = "Pacifico-Regular.ttf"; sourceTree = "<group>"; };
31+
A861FB2C29ED2F19001F2777 /* Dicee.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Dicee.swift; sourceTree = "<group>"; };
32+
A861FB2F29ED3131001F2777 /* DiceView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DiceView.swift; sourceTree = "<group>"; };
2933
A8D19CE529EC4AF000473ACE /* Swift UI.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Swift UI.app"; sourceTree = BUILT_PRODUCTS_DIR; };
3034
A8D19CE829EC4AF100473ACE /* Swift_UIApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Swift_UIApp.swift; sourceTree = "<group>"; };
3135
A8D19CEA29EC4AF100473ACE /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@@ -75,6 +79,15 @@
7579
path = fonts;
7680
sourceTree = "<group>";
7781
};
82+
A861FB2E29ED2F1F001F2777 /* DiceeApp */ = {
83+
isa = PBXGroup;
84+
children = (
85+
A861FB2C29ED2F19001F2777 /* Dicee.swift */,
86+
A861FB2F29ED3131001F2777 /* DiceView.swift */,
87+
);
88+
path = DiceeApp;
89+
sourceTree = "<group>";
90+
};
7891
A8D19CDC29EC4AF000473ACE = {
7992
isa = PBXGroup;
8093
children = (
@@ -118,6 +131,7 @@
118131
children = (
119132
A861FB2229ED28B1001F2777 /* IAmRichApp */,
120133
A861FB2329ED28BF001F2777 /* NadirCardApp */,
134+
A861FB2E29ED2F1F001F2777 /* DiceeApp */,
121135
);
122136
path = Projects;
123137
sourceTree = "<group>";
@@ -206,7 +220,9 @@
206220
buildActionMask = 2147483647;
207221
files = (
208222
A8D19CF929EC4BAF00473ACE /* TextSwiftUI.swift in Sources */,
223+
A861FB3029ED3131001F2777 /* DiceView.swift in Sources */,
209224
A8D19CEB29EC4AF100473ACE /* ContentView.swift in Sources */,
225+
A861FB2D29ED2F19001F2777 /* Dicee.swift in Sources */,
210226
A861FB2129ED27D6001F2777 /* NadirCard.swift in Sources */,
211227
A8E24C4329EC5F670061A1C0 /* ImageSwiftUI.swift in Sources */,
212228
A8D19CF729EC4B7900473ACE /* IAmRich.swift in Sources */,

Swift UI/Swift UI/ContentView.swift

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ struct ContentView: View {
2020

2121
Divider()
2222

23+
Text("Projects")
< ED48 /td>24+
.font(.title2).bold()
25+
.foregroundColor(.green)
26+
2327
ScrollView{
24-
Text("Projects")
25-
.font(.title2).bold()
26-
.foregroundColor(.green)
27-
2828
NavigationLink(destination: IAmRich()) {
2929
Text("I am Rich")
3030
.frame(minWidth: 0, maxWidth: 250)
@@ -45,12 +45,24 @@ struct ContentView: View {
4545
.font(.title3)
4646
}
4747

48-
Divider()
49-
50-
Text("Extras")
51-
.font(.title2).bold()
52-
.foregroundColor(.green)
48+
NavigationLink(destination: Dicee()) {
49+
Text("Dicee")
50+
.frame(minWidth: 0, maxWidth: 250)
51+
.padding()
52+
.foregroundColor(.white)
53+
.background(LinearGradient(gradient: Gradient(colors: [Color.red, Color.blue]), startPoint: .leading, endPoint: .trailing))
54+
.cornerRadius(40)
55+
.font(.title3)
56+
}
5357

58+
Spacer()
59+
}
60+
61+
Text("Extras")
62+
.font(.title2).bold()
63+
.foregroundColor(.green)
64+
65+
ScrollView{
5466
NavigationLink(destination: TextSwiftUI()) {
5567
Text("Text (SwiftUI)")
5668
.frame(minWidth: 0, maxWidth: 250)
@@ -100,6 +112,8 @@ struct ContentView: View {
100112
.cornerRadius(40)
101113
.font(.title3)
102114
}
115+
116+
Spacer()
103117
}
104118
}
105119
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
//
2+
// DiceView.swift
3+
// Swift UI
4+
//
5+
// Created by Nadir Shah on 17/04/2023.
6+
//
7+
8+
import SwiftUI
9+
10+
struct DiceView: View {
11+
12+
let n: Int
13+
14+
var body: some View {
15+
Image("dice\(n)")
16+
.resizable()
17+
.aspectRatio(1, contentMode: .fit)
18+
.padding()
19+
}
20+
}
21+
22+
struct DiceView_Previews: PreviewProvider {
23+
static var previews: some View {
24+
DiceView(n: 1)
25+
.previewLayout(.sizeThatFits)
26+
}
27+
}
Lines changed: 53 additions & 0 deletions
< 59F6 /tr>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
//
2+
// Dicee.swift
3+
// Swift UI
4+
//
5+
// Created by Nadir Shah on 17/04/2023.
6+
//
7+
8+
import SwiftUI
9+
10+
struct Dicee: View {
11+
12+
@State var leftDiceNumber = 1
13+
@State var rightDiceNumber = 1
14+
15+
var body: some View {
16+
ZStack {
17+
Image("background")
18+
.resizable()
19+
.edgesIgnoringSafeArea(.all)
20+
21+
VStack {
22+
Image("diceeLogo")
23+
24+
Spacer()
25+
26+
HStack {
27+
DiceView(n: leftDiceNumber)
28+
DiceView(n: rightDiceNumber)
29+
}
30+
.padding(.horizontal)
31+
32+
Spacer()
33+
34+
Button(action: {
35+
self.leftDiceNumber = Int.random(in: 1...6)
36+
self.rightDiceNumber = Int.random(in: 1...6)
37+
}) {
38+
Text("Roll")
39+
.font(Font.custom("Pacifico-Regular", size: 40))
40+
.bold()
41+
.foregroundColor(.white)
42+
.padding(.horizontal)
43+
}.background(.red)
44+
}
45+
}
46+
}
47+
}
48+
49+
struct Dicee_Previews: PreviewProvider {
50+
static var previews: some View {
51+
Dicee()
52+
}
53+
}

0 commit comments

Comments
 (0)
0