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
Binary file added .DS_Store
Binary file not shown.
Binary file added Athena/.DS_Store
Binary file not shown.
375 changes: 375 additions & 0 deletions Athena/Athena.xcodeproj/project.pbxproj

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>
Binary file not shown.
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>Athena.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
11 changes: 11 additions & 0 deletions Athena/Athena/Assets.xcassets/AccentColor.colorset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
13 changes: 13 additions & 0 deletions Athena/Athena/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"images" : [
{
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
6 changes: 6 additions & 0 deletions Athena/Athena/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
32 changes: 32 additions & 0 deletions Athena/Athena/AthenaApp.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//
// AthenaApp.swift
// Athena
//
// Created by student on 5/16/24.
//

import SwiftUI
import SwiftData

@main
struct AthenaApp: App {
var sharedModelContainer: ModelContainer = {
let schema = Schema([
Item.self,
])
let modelConfiguration = ModelConfiguration(schema: schema, isStoredInMemoryOnly: false)

do {
return try ModelContainer(for: schema, configurations: [modelConfiguration])
} catch {
fatalError("Could not create ModelContainer: \(error)")
}
}()

var body: some Scene {
WindowGroup {
SearchView()
}
.modelContainer(sharedModelContainer)
}
}
13 changes: 13 additions & 0 deletions Athena/Athena/Category.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Category.swift
// Athena
//
// Created by student on 6/6/24.
//

import Foundation
import SwiftData
struct Category: Codable {
var name: String
var description: String
}
61 changes: 61 additions & 0 deletions Athena/Athena/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
//
// ContentView.swift
// Athena
//
// Created by student on 5/16/24.
//

import SwiftUI
import SwiftData

struct ContentView: View {
@Environment(\.modelContext) private var modelContext
@Query private var items: [Item]

var body: some View {
NavigationSplitView {
List {
ForEach(items) { item in
NavigationLink {
Text("Item at \(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))")
} label: {
Text(item.timestamp, format: Date.FormatStyle(date: .numeric, time: .standard))
}
}
.onDelete(perform: deleteItems)
}
.toolbar {
ToolbarItem(placement: .navigationBarTrailing) {
EditButton()
}
ToolbarItem {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
}
} detail: {
Text("Select an item")
}
}

private func addItem() {
withAnimation {
let newItem = Item(timestamp: Date())
modelContext.insert(newItem)
}
}

private func deleteItems(offsets: IndexSet) {
withAnimation {
for index in offsets {
modelContext.delete(items[index])
}
}
}
}

#Preview {
ContentView()
.modelContainer(for: Item.self, inMemory: true)
}
13 changes: 13 additions & 0 deletions Athena/Athena/Eligibility.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// Eligibility.swift
// Athena
//
// Created by student on 6/6/24.
//

import Foundation
import SwiftData
struct Eligibility: Codable {
var name: String
var description: String
}
18 changes: 18 additions & 0 deletions Athena/Athena/Item.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// Item.swift
// Athena
//
// Created by student on 5/16/24.
//

import Foundation
import SwiftData

@Model
final class Item {
var timestamp: Date

init(timestamp: Date) {
self.timestamp = timestamp
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
115 changes: 115 additions & 0 deletions Athena/Athena/Program.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
//
// Program.swift
// Athena
//
// Created by student on 5/16/24.
//

import SwiftData
import Foundation
struct Program: Codable {
var id: Int
var title: String
var description: String
var categories: [Category]
var eligibilities: [Eligibility]
var date: String
var location: String
var cost: Int
var appDeadline: Date
var link: String
var archived: Bool
}
extension Date {
init(_ dateString:String) {
let dateStringFormatter = DateFormatter()
dateStringFormatter.dateFormat = "yyyy-MM-dd"
dateStringFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") as Locale
let date = dateStringFormatter.date(from: dateString)!
self.init(timeInterval:0, since:date)
}
}

//@Model
//class Program: Identifiable, Codable {
// let id = UUID()
// let name: String = ""
// var descr: String = ""
// var tags: [String]
// let deadline = Date()
// let startDate = Date()
// let endDate = Date()
// let location: String = ""
// let gradeLevel: Int = 0
// let price: Decimal = 0.0
// var applied: Bool = false
//
// enum CodingKeys: String,CodingKey {
// case id, name, descr, tags, deadline, startDate, endDate, location, gradeLevel, price, applied
// }
//
//
// init(name: String, descr: String, deadline: String, tags: [String], startDate: String, endDate: String, location: String, gradeLevel: Int, price: Decimal){
// self.name = name
// self.descr = descr
// for tag in tags{
// self.tags.append(tag)
// }
// self.deadline = toDate(inputDate: deadline)
// self.startDate = toDate(inputDate: startDate)
// self.endDate = toDate(inputDate: endDate)
// self.location = location
// self.gradeLevel = gradeLevel
// self.price = price
// self.applied = false
// }
//
// required init(from decoder: Decoder) throws {
// let container = try decoder.container(keyedBy: CodingKeys.self)
// self.name = try container.decode(String.self, forKey: .name)
// self.descr = try container.decode(String.self, forKey: .descr)
// self.tags = try container.decode([String].self, forKey: .tags)
// self.deadline = try container.decode(Date.self, forKey: .deadline)
// self.startDate = try container.decode(Date.self, forKey: .startDate)
// self.endDate = try container.decode(Date.self, forKey: .endDate)
// self.location = try container.decode(String.self, forKey: .location)
// self.gradeLevel = try container.decode(Int.self, forKey: .gradeLevel)
// self.price = try container.decode(Decimal.self, forKey: .price)
// self.applied = try container.decode(Bool.self, forKey: .applied)
// }
//// func encode(to encoder: Encoder) throws {
//// var container = encoder.container(keyedBy: CodingKeys.self)
//// try container.encode(name, forKey: .name)
//// try container.encode(descr, forKey: .descr)
//// try container.encode(tags, forKey: .tags)
//// try container.encode(deadline, forKey: .deadline)
//// try container.encode(startDate, forKey: .startDate)
//// try container.encode(endDate, forKey: .endDate)
//// try container.encode(location, forKey: .location)
//// try container.encode(gradeLevel, forKey: .gradeLevel)
//// try container.encode(price, forKey: .price)
//// try container.encode(applied, forKey: .applied)
//// }
////
// func decodeJSONFile(fileName: String) throws -> [Program] {
// let decoder = JSONDecoder()
// decoder.dateDecodingStrategy = .iso8601
//
// let path = Bundle.main.path(forResource: "sample.json", ofType: "json")!
// let data = try Data(contentsOf: URL(fileURLWithPath: path))
//
// return try decoder.decode([Program].self, from: data)
// }
//
//
// func toDate(inputDate: String) -> Date{
// let dateFormatter = DateFormatter()
// dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ssZZZ"
// guard let result = dateFormatter.date(from: inputDate) as Date? else{
// let result = Date()
// return result
// }
// return result
// }
//
//}
12 changes: 12 additions & 0 deletions Athena/Athena/Programs.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Programs.swift
// Athena
//
// Created by student on 6/6/24.
//

import Foundation
import SwiftData
struct Programs: Codable {
var programs: [Program]
}
51 changes: 51 additions & 0 deletions Athena/Athena/SearchView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//
// SearchView.swift
// Athena
//
// Created by student on 5/16/24.
//

import Foundation
import SwiftUI
struct SearchView: View {
@State private var programs = [Program]()

var body: some View {
List(programs, id: \.id) { item in
VStack(alignment: .leading) {
Text(item.title)
.font(.headline)
Text(item.description)
}
}
.onAppear(perform: parseJson)
}
func parseJson() {

if let url = Bundle.main.url(forResource: "Opps.json", withExtension: nil){

if let data = try? Data(contentsOf: url){

let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"

let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .formatted(dateFormatter)

do{
let programs = try decoder.decode([Program].self, from: data)
self.programs = programs

}
catch {
print("error trying parse json")
}
}
}
}
}
struct SearchView_Previews: PreviewProvider {
static var previews: some View {
SearchView()
}
}
Loading