-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Karan Bhasin
committed
Jul 26, 2020
1 parent
6af0db6
commit 58fdfe6
Showing
5 changed files
with
132 additions
and
1 deletion.
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
Binary file modified
BIN
+3.53 KB
(110%)
...eproj/project.xcworkspace/xcuserdata/karbhasin.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
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,77 @@ | ||
// | ||
// ContactRow.swift | ||
// SwiftUI_Starter | ||
// | ||
// Created by Karan Bhasin on 26/07/20. | ||
// Copyright © 2020 Karan Bhaisn. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
|
||
struct Contact: Identifiable, Hashable { | ||
|
||
let id: Int | ||
let name: String | ||
let email: String | ||
let number: String | ||
|
||
static func data() -> [Contact] { | ||
return [ | ||
Contact(id: 0, name: "Nila", email: "alash@gmail.com", number: "8884489221"), | ||
Contact(id: 1, name: "Nitin", email: "pant@gmail.com", number: "8884489222"), | ||
Contact(id: 2, name: "Deepak", email: "kumar@gmail.com", number: "8884489223"), | ||
Contact(id: 3,name: "Dileep", email: "dm@gmail.com", number: "8884489224")] | ||
} | ||
} | ||
|
||
struct ContactRow: View { | ||
var cellData: Contact | ||
@State private var showingAlert = false | ||
var body: some View { | ||
HStack(spacing: 10) { | ||
VStack(spacing: 10) { | ||
Text(cellData.name) | ||
Text(cellData.email) | ||
} | ||
Spacer() | ||
Button(action: sendMessage) { | ||
Image(systemName: "message.fill") | ||
.frame(width: 20, height: 20, alignment: .leading) | ||
.foregroundColor(Color.green) | ||
}.alert(isPresented: $showingAlert) { | ||
Alert(title: Text("Coming Soon"), message: Text("We will be live soon with this feature"), dismissButton: .default(Text("Got It!"))) | ||
} | ||
Button(action: makeVideoCall) { | ||
Image(systemName: "video.fill") | ||
.frame(width: 20, height: 20, alignment: .leading) | ||
.foregroundColor(Color.red) | ||
}.alert(isPresented: $showingAlert) { | ||
Alert(title: Text("Coming Soon"), message: Text("We will be live soon with this feature"), dismissButton: .default(Text("Got It!"))) | ||
} | ||
Button(action: buttonAction) { | ||
Image(systemName: "chevron.right") | ||
.frame(width: 20, height: 20) | ||
.foregroundColor(Color.yellow) | ||
} | ||
} | ||
} | ||
|
||
func sendMessage() { | ||
self.showingAlert = true | ||
} | ||
|
||
func makeVideoCall() { | ||
self.showingAlert = true | ||
} | ||
|
||
private func buttonAction() { | ||
|
||
} | ||
} | ||
|
||
struct ContactRow_Previews: PreviewProvider { | ||
static var previews: some View { | ||
ContactRow(cellData: Contact(id: 1, name: "dss", email: "Ds@sdcom", number: "32332")) | ||
} | ||
} |
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,46 @@ | ||
// | ||
// MyContacts.swift | ||
// SwiftUI_Starter | ||
// | ||
// Created by Karan Bhasin on 26/07/20. | ||
// Copyright © 2020 Karan Bhaisn. All rights reserved. | ||
// | ||
|
||
import SwiftUI | ||
|
||
|
||
struct MyContacts: View { | ||
@State private var sortingIndex = 0 | ||
|
||
var body: some View { | ||
NavigationView { | ||
VStack(spacing: 5) { | ||
Text("Scroll List") | ||
Picker("Sort Contacts by", selection: $sortingIndex) { | ||
Text("Name").tag(0) | ||
Text("Email").tag(1) | ||
}.pickerStyle(SegmentedPickerStyle()) | ||
ScrollView { | ||
VStack(spacing: 15) { | ||
ForEach(Contact.data(), id: \.self) { object in | ||
ContactRow(cellData: object) | ||
} | ||
} | ||
} | ||
Text("Table List") | ||
List { | ||
ForEach(Contact.data(), id: \.self) { object in | ||
ContactRow(cellData: object) | ||
} | ||
} | ||
} | ||
.navigationBarTitle("My List") | ||
} | ||
} | ||
} | ||
|
||
struct MyContacts_Previews: PreviewProvider { | ||
static var previews: some View { | ||
MyContacts() | ||
} | ||
} |
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