Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
code change : 3. Add Auth
- Loading branch information
Stormacq, Sebastien
committed
Jun 11, 2020
1 parent
d5e5132
commit 675318f3df24b3893ba849e19214ce719a6b7445
Showing
7 changed files
with
217 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// LandingView.swift | ||
// Landmarks | ||
// Landmarks/LandingView.swift | ||
import SwiftUI | ||
|
||
struct LandingView: View { | ||
@ObservedObject public var user : UserData | ||
|
||
var body: some View { | ||
|
||
return VStack { | ||
// .wrappedValue is used to extract the Bool from Binding<Bool> type | ||
if (!$user.isSignedIn.wrappedValue) { | ||
|
||
Button(action: { | ||
let app = UIApplication.shared.delegate as! AppDelegate | ||
app.authenticateWithHostedUI() | ||
}) { | ||
UserBadge().scaleEffect(0.5) | ||
} | ||
|
||
} else { | ||
LandmarkList().environmentObject(user) | ||
} | ||
} | ||
} | ||
} | ||
|
||
struct LandingView_Previews: PreviewProvider { | ||
static var previews: some View { | ||
let app = UIApplication.shared.delegate as! AppDelegate | ||
return LandingView(user: app.userData) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
/* | ||
See LICENSE folder for this sample’s licensing information. | ||
Abstract: | ||
A model object that stores app data. | ||
*/ | ||
|
||
// Landmarks/Models/UserData.swift | ||
import Combine | ||
import SwiftUI | ||
|
||
final class UserData: ObservableObject { | ||
@Published var showFavoritesOnly = false | ||
@Published var landmarks = landmarkData | ||
@Published var isSignedIn : Bool = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// | ||
// UserBadge.swift | ||
// Landmarks | ||
import SwiftUI | ||
|
||
struct UserBadge: View { | ||
var body: some View { | ||
GeometryReader { geometry in | ||
ZStack { | ||
Circle().stroke(Color.blue, lineWidth: geometry.size.width/50.0) | ||
|
||
VStack { | ||
Circle() | ||
.frame(width:geometry.size.width / 2.0, height:geometry.size.width / 2.0, alignment: .center) | ||
.foregroundColor(.blue) | ||
.offset(x:0, y:geometry.size.width/3.3) | ||
|
||
Circle() | ||
.frame(width:geometry.size.width, height:geometry.size.width, alignment: .center) | ||
.foregroundColor(.blue) | ||
.offset(x:0, y:geometry.size.width/3.0) | ||
|
||
|
||
} | ||
} | ||
.clipShape(Circle()) | ||
.shadow(radius: geometry.size.width/30.0) | ||
} | ||
} | ||
} | ||
|
||
struct UserBadge_Previews: PreviewProvider { | ||
static var previews: some View { | ||
UserBadge() | ||
} | ||
} |