Skip to content

Commit

Permalink
SwiftUI-Segments
Browse files Browse the repository at this point in the history
  • Loading branch information
swasalunke committed Jul 26, 2020
1 parent a005c39 commit 142fbca
Show file tree
Hide file tree
Showing 19 changed files with 1,005 additions and 0 deletions.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "7B60D7D1-9E13-46FF-B64C-FBDE76ED66FF"
type = "1"
version = "2.0">
</Bucket>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>SwiftUI-SegmentControl.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//
// AppDelegate.swift
// SwiftUI-SegmentControl
//
// Created by Salunke, Swapnil Uday (US - Mumbai) on 26/07/20.
// Copyright © 2020 Swapnil Salunke. All rights reserved.
//

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {



func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}

// MARK: UISceneSession Lifecycle

func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}

func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}


}

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{
"images" : [
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "20x20"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "29x29"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "40x40"
},
{
"idiom" : "iphone",
"scale" : "2x",
"size" : "60x60"
},
{
"idiom" : "iphone",
"scale" : "3x",
"size" : "60x60"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "20x20"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "29x29"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "40x40"
},
{
"idiom" : "ipad",
"scale" : "1x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "76x76"
},
{
"idiom" : "ipad",
"scale" : "2x",
"size" : "83.5x83.5"
},
{
"idiom" : "ios-marketing",
"scale" : "1x",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
</document>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// ContactDetails.swift
// SwiftUI-SegmentControl
//
// Created by Salunke, Swapnil Uday (US - Mumbai) on 26/07/20.
// Copyright © 2020 Swapnil Salunke. All rights reserved.
//

import SwiftUI

struct ContactDetails: View {
var contactDetail: ContactInfo
var body: some View {
VStack {
Text(contactDetail.name)
Text(contactDetail.email)
Text(contactDetail.number)
}
}
}

struct ContactDetails_Previews: PreviewProvider {
static var previews: some View {
ContactDetails(contactDetail: ContactInfo(name: "Robert", email: "robert@apple.com", number: "1234567890"))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// ContactInfo.swift
// SwiftUI-SegmentControl
//
// Created by Salunke, Swapnil Uday (US - Mumbai) on 26/07/20.
// Copyright © 2020 Swapnil Salunke. All rights reserved.
//

import SwiftUI

struct ContactInfo: Identifiable, Hashable {
let id = UUID()
let name: String
let email: String
let number: String

static func getDummyData() -> [ContactInfo] {
return [ContactInfo(name: "John", email: "john@apple.com", number: "1234567890"),
ContactInfo(name: "Robert", email: "robert@apple.com", number: "1234567890"),
ContactInfo(name: "Albert", email: "ablert@apple.com", number: "1234567890"),
ContactInfo(name: "Tim", email: "tim@apple.com", number: "1234567890"),
ContactInfo(name: "Steve", email: "steve@apple.com", number: "1234567890"),
ContactInfo(name: "Bruce", email: "john@apple.com", number: "1234567890"),
ContactInfo(name: "Stephanie", email: "stephanie@apple.com", number: "1234567890"),
ContactInfo(name: "Michelle", email: "michelle@apple.com", number: "1234567890"),
ContactInfo(name: "Dorothy", email: "dorothy@apple.com", number: "1234567890")]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// ContactsUI.swift
// SwiftUI-SegmentControl
//
// Created by Salunke, Swapnil Uday (US - Mumbai) on 26/07/20.
// Copyright © 2020 Swapnil Salunke. All rights reserved.
//

import SwiftUI

struct ContactsUICell: View {
@State private var isShowingAlert = false

let contactInfo: ContactInfo
var body: some View {
HStack {
VStack(alignment: .leading, spacing: 5) {
Text(contactInfo.name)
.fontWeight(.bold)
.font(.system(size: 18))
Text(contactInfo.email)
.fontWeight(.semibold)
.font(.system(size: 16))
}
Spacer()
Button(action: makeVideoCall){
Image(systemName: "message.fill")
.frame(width: 40, height: 40, alignment: .center)
.font(.body)
.foregroundColor(Color.green)
}.alert(isPresented: $isShowingAlert) {
Alert(title: Text("In Progress"), message: Text("Once completed you will be able to send messages and make a call"), dismissButton: .default(Text("Got it")))
}
}
}

func makeVideoCall() {

}
}

struct ContactsUI_Previews: PreviewProvider {
static var previews: some View {
ContactsUICell(contactInfo: <#ContactInfo#>)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// ContactsUICell.swift
// SwiftUI-SegmentControl
//
// Created by Salunke, Swapnil Uday (US - Mumbai) on 26/07/20.
// Copyright © 2020 Swapnil Salunke. All rights reserved.
//

import SwiftUI

struct ContactsUICell: View {
@State private var isShowingAlert = false

let contactInfo: ContactInfo
var body: some View {
HStack {
VStack(alignment: .leading, spacing: 5) {
Text(contactInfo.name)
.fontWeight(.bold)
.font(.system(size: 18))
.foregroundColor(Color.black)
Text(contactInfo.email)
.fontWeight(.semibold)
.font(.system(size: 14))
.foregroundColor(Color.black)
}
Spacer()
Button(action: sendMessages){
Image(systemName: "message.fill")
.frame(width: 40, height: 40, alignment: .center)
.font(.body)
.foregroundColor(Color.green)
}.alert(isPresented: $isShowingAlert) {
Alert(title: Text("In Progress"), message: Text("Once completed you will be able to send messages"), dismissButton: .default(Text("Got it")))
}

Button(action: makeVideoCall){
Image(systemName: "video.fill")
.frame(width: 40, height: 40, alignment: .center)
.font(.body)
.foregroundColor(Color.blue)
}.alert(isPresented: $isShowingAlert) {
Alert(title: Text("In Progress"), message: Text("Once completed you will be able to make a video call"), dismissButton: .default(Text("Got it")))
}
}.padding(10)
}

func sendMessages() {
self.isShowingAlert = true
}

func makeVideoCall() {
self.isShowingAlert = true
}
}

struct ContactsUI_Previews: PreviewProvider {
static var previews: some View {
ContactsUICell(contactInfo: ContactInfo(name: "John", email: "john@apple.com", number: "1234567890"))
}
}
Loading

0 comments on commit 142fbca

Please sign in to comment.