Skip to content

Instantly share code, notes, and snippets.

@alyssoncm
alyssoncm / HomeView.swift
Created September 25, 2019 20:49
HomeView
struct HomeView: View {
var body: some View {
GeometryReader { geometry in
VStack{
HStack{
Button(action: {}){
Image("camera")
.resizable()
.frame(width: 30, height: 30)
}.padding()
@alyssoncm
alyssoncm / PreviewViewTop.swift
Created September 25, 2019 20:48
PreviewViewTop
struct PreviewViewTop: View {
var body: some View {
HStack{
VStack {
Image("logo-social")
.resizable()
.frame(width: 60, height: 60)
.clipShape(Circle())
.shadow(radius: 3)
.overlay(Circle().stroke(Color.pink, lineWidth: 1))
@alyssoncm
alyssoncm / geometryReader.swift
Created September 25, 2019 20:45
geometryReader
GeometryReader { geometry in
VStack{
HStack{
Button(action: {}){
Image("camera")
.resizable()
.frame(width: 30, height: 30)
}.padding()
Text("Back4Gram")
@alyssoncm
alyssoncm / button.swift
Created September 23, 2019 20:55
button swift
Button(action: {
// Perform the SignUpUser mutation, passing the parameters we just got from our TextFields
apollo.perform(mutation: SignUpUserMutation(username: self.username, password: self.password, email: self.email)){ result in
// Let's switch the result so we can separate a successful one from an error
switch result {
// In case of success
case .success(let graphQLResult):
// We try to parse our result
if let objId = graphQLResult.data?.users?.signUp.objectId {
myMessage.alertTitle = "Yay!"
@alyssoncm
alyssoncm / apolloSwift2.swift
Created September 23, 2019 20:54
apolloSwift2
// Perform the SignUpUser mutation, passing the parameters we just got from our TextFields
apollo.perform(mutation: SignUpUserMutation(username: self.username, password: self.password, email: self.email)){ result in
// Let's switch the result so we can separate a successful one from an error
switch result {
// In case of success
case .success(let graphQLResult):
// We try to parse our result
if let objId = graphQLResult.data?.users?.signUp.objectId {
print ("User created with ObjectId: " + objId)
}
import Apollo
// Apollo Client initialization.
// More about it here: https://www.back4app.com/docs/ios/swift-graphql
let apollo: ApolloClient = {
let configuration = URLSessionConfiguration.default
configuration.httpAdditionalHeaders = [
"X-Parse-Application-Id": "YourAppIdHere",
"X-Parse-Client-Key": "YourClientKeyHere"
]
@alyssoncm
alyssoncm / strut4.swift
Created September 23, 2019 20:51
strut4
struct SignUpView: View {
@State var username: String = ""
@State var password: String = ""
@State var email: String = ""
let lightGreyColor = Color(red: 239.0/255.0, green: 243.0/255.0, blue: 244.0/255.0, opacity: 1.0)
let lightBlueColor = Color(red: 36.0/255.0, green: 158.0/255.0, blue: 235.0/255.0, opacity: 1.0)
var body: some View {
@alyssoncm
alyssoncm / strut3.swift
Created September 23, 2019 20:48
strut3
struct SignUpView: View {
@State var username: String = ""
@State var password: String = ""
@State var email: String = ""
var body: some View {
VStack{
Text("Sign Up")
TextField("Username", text: $username)
SecureField("Password", text: $password)
@alyssoncm
alyssoncm / strut2.swift
Created September 23, 2019 20:46
strut2
struct SignUpView: View {
var body: some View {
VStack{
Text("Sign Up")
}
}
}
@alyssoncm
alyssoncm / strut.swift
Created September 23, 2019 20:45
strut
struct ContentView: View {
var body: some View {
SignUpView()
}
}