working basic carousel with some dummy data profile pictures
This commit is contained in:
@@ -22,6 +22,7 @@
|
|||||||
891A160B2765732700B26659 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160A2765732700B26659 /* HomeViewModel.swift */; };
|
891A160B2765732700B26659 /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160A2765732700B26659 /* HomeViewModel.swift */; };
|
||||||
891A160E27657CEA00B26659 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160D27657CEA00B26659 /* User.swift */; };
|
891A160E27657CEA00B26659 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A160D27657CEA00B26659 /* User.swift */; };
|
||||||
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A1610276590B000B26659 /* ChatsCarouselView.swift */; };
|
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A1610276590B000B26659 /* ChatsCarouselView.swift */; };
|
||||||
|
891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 891A16122765A44300B26659 /* ChatsCarouselViewModel.swift */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
@@ -42,6 +43,7 @@
|
|||||||
891A160A2765732700B26659 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
|
891A160A2765732700B26659 /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
|
||||||
891A160D27657CEA00B26659 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
|
891A160D27657CEA00B26659 /* User.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = User.swift; sourceTree = "<group>"; };
|
||||||
891A1610276590B000B26659 /* ChatsCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsCarouselView.swift; sourceTree = "<group>"; };
|
891A1610276590B000B26659 /* ChatsCarouselView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsCarouselView.swift; sourceTree = "<group>"; };
|
||||||
|
891A16122765A44300B26659 /* ChatsCarouselViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatsCarouselViewModel.swift; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@@ -162,6 +164,7 @@
|
|||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
891A1610276590B000B26659 /* ChatsCarouselView.swift */,
|
891A1610276590B000B26659 /* ChatsCarouselView.swift */,
|
||||||
|
891A16122765A44300B26659 /* ChatsCarouselViewModel.swift */,
|
||||||
);
|
);
|
||||||
path = ChatsCarouselView;
|
path = ChatsCarouselView;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
@@ -244,6 +247,7 @@
|
|||||||
891A15F5276557AB00B26659 /* colors.swift in Sources */,
|
891A15F5276557AB00B26659 /* colors.swift in Sources */,
|
||||||
891A15F9276563CA00B26659 /* WelcomeView.swift in Sources */,
|
891A15F9276563CA00B26659 /* WelcomeView.swift in Sources */,
|
||||||
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */,
|
891A1611276590B000B26659 /* ChatsCarouselView.swift in Sources */,
|
||||||
|
891A16132765A44300B26659 /* ChatsCarouselViewModel.swift in Sources */,
|
||||||
891A15E127653A7000B26659 /* nirvana_iosApp.swift in Sources */,
|
891A15E127653A7000B26659 /* nirvana_iosApp.swift in Sources */,
|
||||||
891A160127656FB200B26659 /* Footer.swift in Sources */,
|
891A160127656FB200B26659 /* Footer.swift in Sources */,
|
||||||
891A15FF27656F9200B26659 /* HeaderView.swift in Sources */,
|
891A15FF27656F9200B26659 /* HeaderView.swift in Sources */,
|
||||||
|
|||||||
BIN
Binary file not shown.
|
Before Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"images" : [
|
"images" : [
|
||||||
{
|
{
|
||||||
"filename" : "dummy_profile_picture.jpeg",
|
"filename" : "heran.jpeg",
|
||||||
"idiom" : "universal",
|
"idiom" : "universal",
|
||||||
"scale" : "1x"
|
"scale" : "1x"
|
||||||
},
|
},
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "kevin.jpeg",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "liam.jpeg",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 41 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "rohan.jpeg",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 35 KiB |
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"images" : [
|
||||||
|
{
|
||||||
|
"filename" : "sarth.jpeg",
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "1x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "2x"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idiom" : "universal",
|
||||||
|
"scale" : "3x"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"info" : {
|
||||||
|
"author" : "xcode",
|
||||||
|
"version" : 1
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 42 KiB |
@@ -9,10 +9,17 @@ import Foundation
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
class User: Identifiable {
|
class User: Identifiable {
|
||||||
var id = UUID()
|
var id = UUID().uuidString
|
||||||
var profilePictureUrl:String = ""
|
|
||||||
var firstName:String = ""
|
|
||||||
var lastName:String = ""
|
|
||||||
var name:String = ""
|
|
||||||
|
|
||||||
|
var profilePictureUrl:String
|
||||||
|
var firstName:String
|
||||||
|
var lastName:String
|
||||||
|
var name:String?
|
||||||
|
|
||||||
|
init(_id:String = UUID().uuidString, _profilePic:String, _firstN:String, _lastN:String) {
|
||||||
|
self.id = _id
|
||||||
|
self.profilePictureUrl = _profilePic
|
||||||
|
self.firstName = _firstN
|
||||||
|
self.lastName = _lastN
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,44 +8,47 @@
|
|||||||
import SwiftUI
|
import SwiftUI
|
||||||
|
|
||||||
struct ChatsCarouselView: View {
|
struct ChatsCarouselView: View {
|
||||||
|
@StateObject var viewModel:ChatsCarouselViewModel = ChatsCarouselViewModel()
|
||||||
|
|
||||||
var body: some View {
|
var body: some View {
|
||||||
mainCarouselView
|
mainCarouselView
|
||||||
}
|
}
|
||||||
|
|
||||||
var mainCarouselView: some View {
|
var mainCarouselView: some View {
|
||||||
TabView {
|
TabView {
|
||||||
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
|
ForEach(viewModel.carouselUsers) { carouselUser in
|
||||||
GeometryReader {proxy in
|
GeometryReader {proxy in
|
||||||
let minX = proxy.frame(in: .global).minX
|
let minX = proxy.frame(in: .global).minX
|
||||||
|
|
||||||
carouselUser
|
Image(carouselUser.profilePictureUrl)
|
||||||
.rotation3DEffect(.degrees(minX / -10), axis: (x: 0, y: 1, z: 0))
|
.renderingMode(.original)
|
||||||
.shadow(color: Color("Shadow").opacity(0.3), radius: 10, x:0, y:10)
|
.resizable()
|
||||||
.blur(radius: abs(minX) / 40)
|
.aspectRatio(contentMode: .fit)
|
||||||
|
.clipShape(Circle())
|
||||||
Text("\(minX)")
|
.shadow(radius: 10)
|
||||||
|
.padding()
|
||||||
|
.rotation3DEffect(.degrees(minX / -10), axis: (x: 0, y: 1, z: 0))
|
||||||
|
.blur(radius: abs(minX) / 40)
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.tabViewStyle(.page(indexDisplayMode: .always))
|
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||||
.frame(height: 400)
|
.frame(height: 400)
|
||||||
|
.padding(.top, 50)
|
||||||
|
.padding(.horizontal, 30)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//the bottom navigation of the small profile pictures
|
//the bottom navigation of the small profile pictures
|
||||||
// var navigationCarouselView: some View { }
|
// var navigationCarouselView: some View { }
|
||||||
|
|
||||||
var carouselUser: some View {
|
|
||||||
Image("dummy_profile_picture")
|
|
||||||
.renderingMode(.original)
|
|
||||||
.resizable()
|
|
||||||
.aspectRatio(contentMode: .fit)
|
|
||||||
.cornerRadius(0)
|
|
||||||
.clipShape(Circle())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ChatsCarouselView_Previews: PreviewProvider {
|
struct ChatsCarouselView_Previews: PreviewProvider {
|
||||||
static var previews: some View {
|
static var previews: some View {
|
||||||
ChatsCarouselView()
|
HomeView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// ChatsCarouselViewModel.swift
|
||||||
|
// nirvana-ios
|
||||||
|
//
|
||||||
|
// Created by Arjun Patel on 12/11/21.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
final class ChatsCarouselViewModel: ObservableObject {
|
||||||
|
@Published var carouselUsers:[CarouselUser] = []
|
||||||
|
|
||||||
|
init() {
|
||||||
|
carouselUsers = [
|
||||||
|
CarouselUser(_profilePic: "liam", _firstN: "Liam", _lastN: "Digregorio"),
|
||||||
|
CarouselUser(_profilePic: "heran", _firstN: "Heran", _lastN: "Patel"),
|
||||||
|
CarouselUser(_profilePic: "sarth", _firstN: "Sarth", _lastN: "Shah"),
|
||||||
|
CarouselUser(_profilePic: "kevin", _firstN: "Kevin", _lastN: "Le"),
|
||||||
|
CarouselUser(_profilePic: "rohan", _firstN: "Rohan", _lastN: "Chadha")
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class CarouselUser: User {
|
||||||
|
// add anything specific needed in the view for carousel
|
||||||
|
// perhaps notification information for each
|
||||||
|
// their messages?
|
||||||
|
}
|
||||||
|
|
||||||
|
//sample data
|
||||||
@@ -8,6 +8,5 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
final class HomeViewModel: ObservableObject {
|
final class HomeViewModel: ObservableObject {
|
||||||
@Published var personalUsers: [User] = []
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user