Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
Cma-png committed Oct 13, 2024
1 parent 10e6ca0 commit db8aa87
Show file tree
Hide file tree
Showing 11 changed files with 228 additions and 0 deletions.
Empty file.
7 changes: 7 additions & 0 deletions ios/SmartJournal/Resources/Assets.xcassets/Content.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"info" : {
"author" : "xcode",
"version" : 1
}
}

63 changes: 63 additions & 0 deletions ios/SmartJournal/Resources/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<!-- File: ios/SmartJournal/Resources/Info.plist -->
<?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>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<key>UISceneConfigurations</key>
<dict>
<key>UIWindowSceneSessionRoleApplication</key>
<array>
<dict>
<key>UISceneConfigurationName</key>
<string>Default Configuration</string>
<key>UISceneDelegateClassName</key>
<string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
</dict>
</array>
</dict>
</dict>
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
2 changes: 2 additions & 0 deletions ios/SmartJournal/Sources/Models/JournalEntry.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ struct JournalEntry: Identifiable, Codable {
let content: String
var sentiment: String?
}


28 changes: 28 additions & 0 deletions ios/SmartJournal/Sources/Services/LLMService.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// File: ios/SmartJournal/Sources/Services/LLMService.swift
import Foundation
import Combine

class LLMService {
private let baseURL = "https://your-backend-url.com/api"

func analyzeEntry(_ entry: JournalEntry) -> AnyPublisher<String, Error> {
let url = URL(string: "\(baseURL)/analyze")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("application/json", forHTTPHeaderField: "Content-Type")

let body = ["content": entry.content]
request.httpBody = try? JSONEncoder().encode(body)

return URLSession.shared.dataTaskPublisher(for: request)
.map { $0.data }
.decode(type: AnalysisResponse.self, decoder: JSONDecoder())
.map { $0.advice }
.eraseToAnyPublisher()
}
}

struct AnalysisResponse: Codable {
let sentiment: String
let advice: String
}
10 changes: 10 additions & 0 deletions ios/SmartJournal/Sources/ViewModels/JournalViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ class JournalViewModel: ObservableObject {
.store(in: &cancellables)
}
}

// File: ios/SmartJournal/Sources/ViewModels/JournalViewModel.swift
// Add this method to the existing JournalViewModel class
extension JournalViewModel {
func getAdvice(for entry: JournalEntry) -> String? {
// In a real app, you would call your LLM service here
// This is a placeholder implementation
return "Based on your entry, consider taking a short walk to clear your mind."
}
}
22 changes: 22 additions & 0 deletions ios/SmartJournal/Sources/Views/EnterRowView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// File: ios/SmartJournal/Sources/Views/EntryRowView.swift
import SwiftUI

struct EntryRowView: View {
let entry: JournalEntry

var body: some View {
VStack(alignment: .leading, spacing: 8) {
Text(entry.date, style: .date)
.font(.subheadline)
.foregroundColor(.secondary)
Text(entry.content)
.font(.body)
.lineLimit(2)
if let sentiment = entry.sentiment {
Text("Sentiment: \(sentiment)")
.font(.caption)
.foregroundColor(.secondary)
}
}
}
}
35 changes: 35 additions & 0 deletions ios/SmartJournal/Sources/Views/EntryDetailView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// File: ios/SmartJournal/Sources/Views/EntryDetailView.swift
import SwiftUI

struct EntryDetailView: View {
let entry: JournalEntry
@ObservedObject var viewModel: JournalViewModel

var body: some View {
ScrollView {
VStack(alignment: .leading, spacing: 16) {
Text(entry.date, style: .date)
.font(.subheadline)
.foregroundColor(.secondary)

Text(entry.content)
.font(.body)

if let sentiment = entry.sentiment {
Text("Sentiment: \(sentiment)")
.font(.subheadline)
.foregroundColor(.secondary)
}

if let advice = viewModel.getAdvice(for: entry) {
Text("Advice:")
.font(.headline)
Text(advice)
.font(.body)
}
}
.padding()
}
.navigationTitle("Journal Entry")
}
}
35 changes: 35 additions & 0 deletions ios/SmartJournal/Sources/Views/NewEntryView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// File: ios/SmartJournal/Sources/Views/NewEntryView.swift
import SwiftUI

struct NewEntryView: View {
@ObservedObject var viewModel: JournalViewModel
@State private var content: String = ""
@Environment(\.presentationMode) var presentationMode

var body: some View {
NavigationView {
Form {
Section(header: Text("New Entry")) {
TextEditor(text: $content)
.frame(height: 200)
}
}
.navigationTitle("New Entry")
.toolbar {
ToolbarItem(placement: .cancellationAction) {
Button("Cancel") {
presentationMode.wrappedValue.dismiss()
}
}
ToolbarItem(placement: .confirmationAction) {
Button("Save") {
let newEntry = JournalEntry(id: UUID().uuidString, date: Date(), content: content)
viewModel.addEntry(newEntry)
presentationMode.wrappedValue.dismiss()
}
.disabled(content.isEmpty)
}
}
}
}
}
3 changes: 3 additions & 0 deletions ios/SmartJournal/fastlane/Appfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# File: ios/fastlane/Appfile
app_identifier("com.yourcompany.SmartJournal") # The bundle identifier of your app
apple_id("your@apple.id") # Your Apple ID
23 changes: 23 additions & 0 deletions ios/SmartJournal/fastlane/Fastfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#File: ios/fastlane/Fastfile
default_platform(:ios)

platform :ios do
desc "Run tests"
lane :test do
run_tests(scheme: "SmartJournal")
end

desc "Build and upload to TestFlight"
lane :beta do
increment_build_number
build_app(scheme: "SmartJournal")
upload_to_testflight
end

desc "Build and upload to App Store"
lane :release do
increment_build_number
build_app(scheme: "SmartJournal")
upload_to_app_store
end
end

0 comments on commit db8aa87

Please sign in to comment.