Skip to content

Commit

Permalink
State
Browse files Browse the repository at this point in the history
  • Loading branch information
its-dev-fer committed Aug 23, 2020
1 parent dbc2b25 commit 37fa5c8
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 1 deletion.
4 changes: 4 additions & 0 deletions StateLesson.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
EDAB874C24F23485003F4511 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDAB874B24F23485003F4511 /* Assets.xcassets */; };
EDAB874F24F23485003F4511 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = EDAB874E24F23485003F4511 /* Preview Assets.xcassets */; };
EDAB875224F23485003F4511 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = EDAB875024F23485003F4511 /* LaunchScreen.storyboard */; };
EDAB875A24F236FF003F4511 /* Amigos.swift in Sources */ = {isa = PBXBuildFile; fileRef = EDAB875924F236FF003F4511 /* Amigos.swift */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -24,6 +25,7 @@
EDAB874E24F23485003F4511 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
EDAB875124F23485003F4511 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
EDAB875324F23485003F4511 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EDAB875924F236FF003F4511 /* Amigos.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Amigos.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -63,6 +65,7 @@
EDAB875024F23485003F4511 /* LaunchScreen.storyboard */,
EDAB875324F23485003F4511 /* Info.plist */,
EDAB874D24F23485003F4511 /* Preview Content */,
EDAB875924F236FF003F4511 /* Amigos.swift */,
);
path = StateLesson;
sourceTree = "<group>";
Expand Down Expand Up @@ -149,6 +152,7 @@
EDAB874624F23483003F4511 /* AppDelegate.swift in Sources */,
EDAB874824F23483003F4511 /* SceneDelegate.swift in Sources */,
EDAB874A24F23483003F4511 /* ContentView.swift in Sources */,
EDAB875A24F236FF003F4511 /* Amigos.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
18 changes: 18 additions & 0 deletions StateLesson/Amigos.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Amigos.swift
// StateLesson
//
// Created by Ingeniero Fernando on 23/08/20.
// Copyright © 2020 Ingeniero Fernando. All rights reserved.
//

import Foundation
import SwiftUI

struct Amigos: Identifiable{
let id = UUID()
let name: String
let apellido: String
let imagen: String
let amigo: Bool
}
21 changes: 21 additions & 0 deletions StateLesson/Assets.xcassets/user1.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user1.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions StateLesson/Assets.xcassets/user2.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user2.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions StateLesson/Assets.xcassets/user3.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user3.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions StateLesson/Assets.xcassets/user4.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "user4.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 38 additions & 1 deletion StateLesson/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,45 @@
import SwiftUI

struct ContentView: View {
@State private var nombre = "Fernando"
@State private var val1:Int = 10 // Esta podrá cambiar su valor
@State private var esAmigo: Bool = true
@State private var amigos = [Amigos]()

private func agregarAmigos(){
self.amigos.append(Amigos(name: "André", apellido: "Sánchez", imagen: "user1", amigo: true))
self.amigos.append(Amigos(name: "David", apellido: "Pérez", imagen: "user2", amigo: true))
self.amigos.append(Amigos(name: "Sebastián", apellido: "Vidal", imagen: "user3", amigo: true))
self.amigos.append(Amigos(name: "Roberto", apellido: "Blanco", imagen: "user4", amigo: true))
self.amigos.append(Amigos(name: "Alguien", apellido: "X", imagen: "user4", amigo: false))
}

var body: some View {
Text("Hello, World!")
VStack {
Button(action:agregarAmigos){
Text("Agregar Amigos")
}
List {
Toggle(isOn: self.$esAmigo){
Text("Solo amigos")
}
ForEach(amigos.filter{$0.amigo == self.esAmigo}) { amigo in
HStack{
Image(amigo.imagen)
.resizable()
.frame(width: 50, height: 50)
VStack(alignment: .leading){
Text(amigo.name)
.font(.title)
.bold()
Text(amigo.apellido)
.font(.subheadline)
}

}
}
}
}
}
}

Expand Down

0 comments on commit 37fa5c8

Please sign in to comment.