Skip to content
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
15 changes: 11 additions & 4 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ on:
jobs:
snyk:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: snyk/actions/setup@v1
- run: snyk auth ${{ secrets.SNYK_TOKEN }}
- run: snyk test --all-projects
- uses: actions/checkout@v3

- name: Set up Snyk CLI
uses: snyk/actions/setup@master # Correct action tag

- name: Authenticate with Snyk
run: snyk auth ${{ secrets.SNYK_TOKEN }}

- name: Run Snyk Code Analysis
run: snyk code test --all-projects
Binary file not shown.
18 changes: 13 additions & 5 deletions AIReviewSwiftUI/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,45 @@

import SwiftUI

import SwiftUI

struct ContentView: View {
@StateObject private var viewModel = TaskViewModel()
@State private var newTaskTitle = ""
@State private var newTaskDueDate = Date()

var body: some View {
VStack {
TextField("Enter task...", text: $newTaskTitle)
.textFieldStyle(RoundedBorderTextFieldStyle())
.padding()

DatePicker("Due Date", selection: $newTaskDueDate, displayedComponents: .date)
.padding()

Button("Add Task") {
viewModel.addTask(title: newTaskTitle)
newTaskTitle = ""
}

TaskSummaryView(
totalTasks: viewModel.tasks.count,
completedTasks: viewModel.completedTasks,
overdueTasks: viewModel.overdueTasks
)

List {
ForEach(viewModel.tasks) { task in
HStack {
Text(task.title)
Spacer()
Text(task.dueDate?.formatted(date: .abbreviated, time: .omitted) ?? "No Due Date")
.font(.caption)
.foregroundColor(.gray)
Button(action: { viewModel.toggleComplete(task) }) {
Image(systemName: task.isCompleted ? "checkmark.circle.fill" : "circle")
}
}
}
}

Text("Total: \(viewModel.tasks.count) • Completed: \(viewModel.tasks.filter { $0.isCompleted }.count)")
.padding(.top)
}
.padding()
}
Expand Down
1 change: 1 addition & 0 deletions AIReviewSwiftUI/Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ struct Task: Identifiable {
let id = UUID()
var title: String
var isCompleted: Bool = false
var dueDate: Date? = nil
}
46 changes: 46 additions & 0 deletions AIReviewSwiftUI/TaskSummaryView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// TaskSummaryView.swift
// AIReviewSwiftUI
//
// Created by kanagasabapathy on 25.04.25.
//

import SwiftUI

struct TaskSummaryView: View {
let totalTasks: Int
let completedTasks: Int
let overdueTasks: Int

var body: some View {
VStack {
Text("Task Summary")
.font(.headline)
.padding(.bottom, 8)

HStack {
Text("Total Tasks:")
Spacer()
Text("\(totalTasks)")
}
.padding(.vertical, 4)

HStack {
Text("Completed Tasks:")
Spacer()
Text("\(completedTasks)")
}
.padding(.vertical, 4)

HStack {
Text("Overdue Tasks:")
Spacer()
Text("\(overdueTasks)")
}
.padding(.vertical, 4)
}
.padding()
.background(RoundedRectangle(cornerRadius: 10).fill(Color(.systemGray6)))
.padding()
}
}
25 changes: 23 additions & 2 deletions AIReviewSwiftUI/TaskViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,38 @@


import Foundation
import CryptoKit



final class TaskViewModel: ObservableObject {
@Published var tasks: [Task] = []

let urlString = "https://dummyjson.com/products"
let password = "user-password"
let userInput = "example.com"

func addTask(title: String) {
guard !title.isEmpty else { return }
let url = URL(string: urlString)!
let hashed = Insecure.MD5.hash(data: password.data(using: .utf8)!)
let urlExample = URL(string: "https://\(userInput)")!
tasks.append(Task(title: title))
}

func toggleComplete(_ task: Task) {
guard let index = tasks.firstIndex(where: { $0.id == task.id }) else { return }
tasks[index].isCompleted.toggle()
}
}
func removeTask(_ task: Task) {
guard let index = tasks.firstIndex(where: { $0.id == task.id }) else { return }
tasks.remove(at: index)
}
var completedTasks: Int {
tasks.filter { $0.isCompleted }.count
}

var overdueTasks: Int {
let now = Date()
return tasks.filter { !$0.isCompleted && ($0.dueDate ?? now) < now }.count
}
}
Loading