working basic carousel with some dummy data profile pictures
This commit is contained in:
@@ -8,44 +8,47 @@
|
||||
import SwiftUI
|
||||
|
||||
struct ChatsCarouselView: View {
|
||||
@StateObject var viewModel:ChatsCarouselViewModel = ChatsCarouselViewModel()
|
||||
|
||||
var body: some View {
|
||||
mainCarouselView
|
||||
}
|
||||
|
||||
var mainCarouselView: some View {
|
||||
TabView {
|
||||
ForEach(/*@START_MENU_TOKEN@*/0 ..< 5/*@END_MENU_TOKEN@*/) { item in
|
||||
ForEach(viewModel.carouselUsers) { carouselUser in
|
||||
GeometryReader {proxy in
|
||||
let minX = proxy.frame(in: .global).minX
|
||||
|
||||
carouselUser
|
||||
.rotation3DEffect(.degrees(minX / -10), axis: (x: 0, y: 1, z: 0))
|
||||
.shadow(color: Color("Shadow").opacity(0.3), radius: 10, x:0, y:10)
|
||||
.blur(radius: abs(minX) / 40)
|
||||
|
||||
Text("\(minX)")
|
||||
|
||||
Image(carouselUser.profilePictureUrl)
|
||||
.renderingMode(.original)
|
||||
.resizable()
|
||||
.aspectRatio(contentMode: .fit)
|
||||
.clipShape(Circle())
|
||||
.shadow(radius: 10)
|
||||
.padding()
|
||||
.rotation3DEffect(.degrees(minX / -10), axis: (x: 0, y: 1, z: 0))
|
||||
.blur(radius: abs(minX) / 40)
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
.tabViewStyle(.page(indexDisplayMode: .always))
|
||||
.frame(height: 400)
|
||||
.padding(.top, 50)
|
||||
.padding(.horizontal, 30)
|
||||
|
||||
}
|
||||
|
||||
//the bottom navigation of the small profile pictures
|
||||
// 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 {
|
||||
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
|
||||
|
||||
final class HomeViewModel: ObservableObject {
|
||||
@Published var personalUsers: [User] = []
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user