Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nick new #3

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{
"originHash" : "ccc727310637079b7355ccf59e7d153c26677020c1a43e177b78cc9df7963c0f",
"pins" : [
{
"identity" : "supabase-swift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/supabase/supabase-swift.git",
"state" : {
"revision" : "24c6b2252f35cdd45e546bb5ea2c684c963df726",
"version" : "2.20.5"
}
},
{
"identity" : "swift-asn1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6",
"version" : "1.3.0"
}
},
{
"identity" : "swift-concurrency-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-concurrency-extras",
"state" : {
"revision" : "6054df64b55186f08b6d0fd87152081b8ad8d613",
"version" : "1.2.0"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "8fa345c2081cfbd4851dffff5dd5bed48efe6081",
"version" : "3.9.0"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types.git",
"state" : {
"revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd",
"version" : "1.3.0"
}
},
{
"identity" : "xctest-dynamic-overlay",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/xctest-dynamic-overlay",
"state" : {
"revision" : "770f990d3e4eececb57ac04a6076e22f8c97daeb",
"version" : "1.4.2"
}
}
],
"version" : 3
}
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>Oasis-front-end.xcscheme_^#shared#^_</key>
<key>ChoreChamp.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//
// AddView.swift
// SupaFeatures
// ChoreChamp
//
// Created by Mikaela Caron on 7/23/23.
// Created by Nick Chen on 11/3/24.
//

import SwiftUI
Expand All @@ -17,25 +17,19 @@ struct AddView: View {

var body: some View {
Form {
TextField("Feature Description", text: $text)
TextField("Chore Description", text: $text)
}
.toolbar {
ToolbarItem {
Button {
Task {
try await viewModel.createFeatureRequest(text: text)
try await viewModel.createTaskRequest(name: text)
dismiss()
}
} label: {
Text("Send")
Text("Add")
}
}
}
}
}

struct AddView_Previews: PreviewProvider {
static var previews: some View {
AddView(viewModel: ViewModel())
}
}
21 changes: 21 additions & 0 deletions ChoreChamp/Assets.xcassets/signupbackground.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "signupbackground.jpeg",
"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.
69 changes: 69 additions & 0 deletions ChoreChamp/AuthView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
//
// AuthView.swift
// ChoreChamp
//
// Created by Nick Chen on 11/3/24.
//

import SwiftUI

struct AuthView: View {

@ObservedObject var viewModel: ViewModel

@Environment(\.dismiss) var dismiss

var body: some View {
NavigationStack {
ZStack {
// Background Image
Image("signupbackground")
.resizable()
.scaledToFill()
.ignoresSafeArea() // Makes the image cover the whole screen
// Overlay Content
VStack(spacing: 20) {
Text("Welcome to ChoreChamp")
.foregroundColor(.white)
.font(.system(size: 43))
Picker("Sign Up or Sign In", selection: $viewModel.authAction) {
ForEach(AuthAction.allCases, id: \.rawValue) { action in
Text(action.rawValue).tag(action)
}
}
.pickerStyle(.segmented)
.padding(.horizontal)

TextField("Email", text: $viewModel.email)
.padding()
.background(Color.white.opacity(0.8))
.cornerRadius(8)
.padding(.horizontal)

SecureField("Password", text: $viewModel.password)
.padding()
.background(Color.white.opacity(0.8))
.cornerRadius(8)
.padding(.horizontal)

// Button for Signing In or Signing Up
Button {
Task {
try await viewModel.authorize()
dismiss()
}
} label: {
Text(viewModel.authAction.rawValue)
.fontWeight(.semibold)
.foregroundColor(.white)
.padding()
.frame(maxWidth: .infinity)
.background(Color.blue)
.cornerRadius(10)
}
.padding(.horizontal)
} //vstack ends here
} //zstack ends here
}
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
//
// SupaFeaturesApp.swift
// SupaFeatures
// ChoreChampApp.swift
// ChoreChamp
//
// Created by Mikaela Caron on 7/23/23.
// Created by Nick Chen on 11/3/24.
//

import SwiftUI

@main
struct SupaFeaturesApp: App {
struct ChoreChampApp: App {
var body: some Scene {
WindowGroup {
ContentView()
Expand Down
34 changes: 34 additions & 0 deletions ChoreChamp/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// ContentView.swift
// NickChoreChamp
//
// Created by Nick Chen on 11/2/24.
//

import SwiftUI
import Supabase

struct ContentView: View {

@State private var isAuthenticated = false

let supabase = SupabaseClient(supabaseURL: Secrets.projectURL, supabaseKey: Secrets.apiKey)

@StateObject private var viewModel = ViewModel()

var body: some View {
Group {
if viewModel.isAuthenticated {
TasksListView();
}
else {
AuthView(viewModel: viewModel)
}
}
}
}

#Preview {
ContentView()
}

49 changes: 49 additions & 0 deletions ChoreChamp/Models.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
//
// Task.swift
// ChoreChamp
//
// Created by Nick Chen on 11/3/24.
//

import Foundation

// TODO: create a model for each table

struct TaskItem: Codable, Identifiable, Hashable {
var id: Int?
var taskName: String
var createdAt: String
var completed: Bool
var dueDate: String
var userId: UUID
var tradable: Bool

enum CodingKeys: String, CodingKey {
case completed, tradable
case id = "task_id"
case taskName = "task_name"
case createdAt = "created_at"
case dueDate = "due_date"
case userId = "user_id"
}
}

struct User: Codable {
var createdAt: String
var email: String
var displayName: String
var profilePictureId: String
var groupId: Int?
var endorsementScore: Float
var userId: Int?

enum CodingKeys: String, CodingKey {
case createdAt = "created_at"
case email
case displayName = "display_name"
case profilePictureId = "profile_picture_id"
case groupId = "group_id"
case endorsementScore = "endorsement_score"
case userId = "user_id"
}
}
39 changes: 39 additions & 0 deletions ChoreChamp/ProfilePicture.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// ProfilePicture.swift
// ChoreChamp
//
// Created by Nick Chen on 11/4/24.
//

import Foundation
import SwiftUI

struct ProfilePicture: Transferable, Equatable {
let image: Image
let data: Data

static var transferRepresentation: some TransferRepresentation {
DataRepresentation(importedContentType: .image) { data in
guard let image = ProfilePicture(data: data) else {
throw TransferError.importFailed
}

return image
}
}
}

extension ProfilePicture {
init?(data: Data) {
guard let uiImage = UIImage(data: data) else {
return nil
}

let image = Image(uiImage: uiImage)
self.init(image: image, data: data)
}
}

enum TransferError: Error {
case importFailed
}
Loading