Thomas Richardson commited on
Commit
cb71d19
·
unverified ·
2 Parent(s): c92f1852c44d83

Merge pull request #210 from ttt246/feature/ios_watch_app_103

Browse files
WatchApp/WatchApp Watch App/Assets.xcassets/.DS_Store ADDED
Binary file (6.15 kB). View file
 
WatchApp/WatchApp Watch App/Assets.xcassets/AccentColor.colorset/Contents.json ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "colors" : [
3
+ {
4
+ "idiom" : "universal"
5
+ }
6
+ ],
7
+ "info" : {
8
+ "author" : "xcode",
9
+ "version" : 1
10
+ }
11
+ }
WatchApp/WatchApp Watch App/Assets.xcassets/AppIcon.appiconset/Contents.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "images" : [
3
+ {
4
+ "idiom" : "universal",
5
+ "platform" : "watchos",
6
+ "size" : "1024x1024"
7
+ }
8
+ ],
9
+ "info" : {
10
+ "author" : "xcode",
11
+ "version" : 1
12
+ }
13
+ }
WatchApp/WatchApp Watch App/Assets.xcassets/Contents.json ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ {
2
+ "info" : {
3
+ "author" : "xcode",
4
+ "version" : 1
5
+ }
6
+ }
WatchApp/WatchApp Watch App/Components/ChatMessageRow.swift CHANGED
@@ -1,57 +1,92 @@
1
- //
2
- // MessageView.swift
3
- // WatchApp Watch App
4
- //
5
- // Created by DarkHorse on 7/1/23.
6
- //
7
-
8
  import SwiftUI
9
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  struct ChatMessage: Hashable {
 
11
  let message: String
12
- let isUser: Bool
 
13
  }
14
 
15
  struct ChatBubble: Shape {
16
- let isUser: Bool
17
-
18
  func path(in rect: CGRect) -> Path {
19
  let path = UIBezierPath(roundedRect: rect,
20
- byRoundingCorners: [.topLeft, .topRight, isUser ? .bottomLeft : .bottomRight],
21
- cornerRadii: CGSize(width: 3, height: 3))
22
  return Path(path.cgPath)
23
  }
24
  }
25
 
26
  struct ChatMessageRow: View {
27
- let message: ChatMessage
28
 
29
  var body: some View {
30
  HStack {
31
- if message.isUser {
 
32
  Spacer()
33
- Text(message.message)
34
  .font(.system(size: 15))
35
  .foregroundColor(.white)
36
  .padding(5)
37
- .background(Color.blue)
38
- .clipShape(ChatBubble(isUser: message.isUser))
39
- } else {
40
- Text(message.message)
41
- .italic()
42
  .font(.system(size: 15))
43
  .foregroundColor(.black)
44
  .padding(5)
45
  .background(Color.primary)
46
- .clipShape(ChatBubble(isUser: message.isUser))
47
  Spacer()
 
 
 
 
 
 
 
 
 
 
 
 
48
  }
49
- }.listRowBackground(Color.clear)
 
 
 
 
 
 
 
 
 
 
 
50
  }
 
51
  }
52
 
53
  struct ChatMessageRow_Previews: PreviewProvider {
54
  static var previews: some View {
55
- ChatMessageRow(message: ChatMessage(message: "Hello!", isUser: false))
 
 
 
 
 
 
56
  }
57
  }
 
 
 
 
 
 
 
 
1
  import SwiftUI
2
 
3
+ public enum TypeChat: String {
4
+ case SEND = "SEND"
5
+ case RECEIVE = "RECEIVE"
6
+ case WIDGET = "WIDGET"
7
+ }
8
+
9
+ public enum TypeWidget: String {
10
+ case EMPTY = "EMPTY"
11
+ case CONTACT = "CONTACT"
12
+ case IMAGE = "IMAGE"
13
+ }
14
+
15
  struct ChatMessage: Hashable {
16
+ let type: TypeChat
17
  let message: String
18
+ let widgetType: TypeWidget
19
+ let widgetDesc: String
20
  }
21
 
22
  struct ChatBubble: Shape {
 
 
23
  func path(in rect: CGRect) -> Path {
24
  let path = UIBezierPath(roundedRect: rect,
25
+ byRoundingCorners: [.allCorners],
26
+ cornerRadii: CGSize(width: 9, height: 9))
27
  return Path(path.cgPath)
28
  }
29
  }
30
 
31
  struct ChatMessageRow: View {
32
+ let chatItem: ChatMessage
33
 
34
  var body: some View {
35
  HStack {
36
+ switch chatItem.type {
37
+ case TypeChat.SEND:
38
  Spacer()
39
+ Text(chatItem.message)
40
  .font(.system(size: 15))
41
  .foregroundColor(.white)
42
  .padding(5)
43
+ .background(Color.green)
44
+ .clipShape(ChatBubble())
45
+ case TypeChat.RECEIVE:
46
+ Text(chatItem.message)
 
47
  .font(.system(size: 15))
48
  .foregroundColor(.black)
49
  .padding(5)
50
  .background(Color.primary)
51
+ .clipShape(ChatBubble())
52
  Spacer()
53
+ case TypeChat.WIDGET:
54
+ switch chatItem.widgetType {
55
+ case TypeWidget.CONTACT:
56
+ let contact = convertStringToContact(jsonData: chatItem.widgetDesc)
57
+ NavigationLink(destination: ContactView(contact: contact)){
58
+ ContactRow(contact: contact)
59
+ }
60
+ case TypeWidget.IMAGE:
61
+ ImageRow()
62
+ default:
63
+ EmptyView()
64
+ }
65
  }
66
+ }.padding(5)
67
+ }
68
+ }
69
+
70
+ func convertStringToContact(jsonData: String) -> Contact {
71
+ do {
72
+ let jsonData = jsonData.data(using: .utf8)!
73
+ let contact = try JSONDecoder().decode(Contact.self, from: jsonData)
74
+
75
+ return contact
76
+ } catch {
77
+ print("Error converting JSON string to object: \(error)")
78
  }
79
+ return Contact(contactId: "", displayName: "Empty", phoneNumbers: [])
80
  }
81
 
82
  struct ChatMessageRow_Previews: PreviewProvider {
83
  static var previews: some View {
84
+ ChatMessageRow(chatItem:ChatMessage(
85
+ type: TypeChat.WIDGET,
86
+ message: "Hello!",
87
+ widgetType: TypeWidget.IMAGE,
88
+ widgetDesc: "Nothing"
89
+ )
90
+ )
91
  }
92
  }
WatchApp/WatchApp Watch App/Components/ContactRow.swift ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import SwiftUI
2
+
3
+ class Contact : Codable {
4
+ var contactId: String
5
+ var displayName: String
6
+ var phoneNumbers: [String]
7
+
8
+ init(contactId: String, displayName: String, phoneNumbers: [String]) {
9
+ self.contactId = contactId
10
+ self.displayName = displayName
11
+ self.phoneNumbers = phoneNumbers
12
+ }
13
+ }
14
+
15
+ struct ContactBubble: Shape {
16
+ func path(in rect: CGRect) -> Path {
17
+ let path = UIBezierPath(roundedRect: rect,
18
+ byRoundingCorners: [.allCorners],
19
+ cornerRadii: CGSize(width: 9, height: 9))
20
+ return Path(path.cgPath)
21
+ }
22
+ }
23
+
24
+ struct ContactRow: View {
25
+ let contact: Contact
26
+
27
+ var body: some View {
28
+ HStack {
29
+ Text(contact.displayName)
30
+ .italic()
31
+ .font(.system(size: 15))
32
+ .foregroundColor(.white)
33
+ .padding(5)
34
+ Spacer()
35
+ Image(systemName: "phone.fill")
36
+ .resizable()
37
+ .frame(width: 17, height: 17)
38
+ .foregroundColor(.white)
39
+ }
40
+ .background(Color.clear)
41
+ .clipShape(ContactBubble())
42
+ }
43
+ }
44
+
45
+ struct Contact_Previews: PreviewProvider {
46
+ static var previews: some View {
47
+ ContactRow(contact: Contact(
48
+ contactId: "5",
49
+ displayName: "Peter Luo",
50
+ phoneNumbers: ["123-234-345"])
51
+ )
52
+ }
53
+ }
WatchApp/WatchApp Watch App/Components/ImageRow.swift ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import SwiftUI
2
+
3
+ struct ImageRow: View {
4
+ var body: some View {
5
+ HStack {
6
+ AsyncImage(url: URL(string: "https://firebasestorage.googleapis.com/v0/b/test3-83ffc.appspot.com/o/images%2F00c08a46-8812-4b3c-ad9f-72d8d04a9368?alt=media&token=cacba50a-0241-445a-892b-5a0661aaaa19")) { image in
7
+ image.resizable().aspectRatio(contentMode: .fit)
8
+ } placeholder: {
9
+ ProgressView()
10
+ }
11
+ }.padding(5).background(Color.white).clipShape(ChatBubble())
12
+ }
13
+ }
14
+
15
+
16
+
17
+ struct ImageRow_Previews: PreviewProvider {
18
+ static var previews: some View {
19
+ ImageRow()
20
+ }
21
+ }
WatchApp/WatchApp Watch App/MainView.swift CHANGED
@@ -1,22 +1,10 @@
1
- //
2
- // MainView.swift
3
- // WatchApp Watch App
4
- //
5
- // Created by DarkHorse on 7/1/23.
6
- //
7
-
8
  import SwiftUI
9
 
10
  struct MainView: View {
11
- @State private var isPresented = false
12
 
13
  var body: some View {
14
- ZStack {
15
- if isPresented {
16
- SettingView(isPresented: $isPresented)
17
- } else {
18
- ChatView(isPresented: $isPresented)
19
- }
20
  }
21
  }
22
  }
 
 
 
 
 
 
 
 
1
  import SwiftUI
2
 
3
  struct MainView: View {
 
4
 
5
  var body: some View {
6
+ NavigationView {
7
+ ChatView()
 
 
 
 
8
  }
9
  }
10
  }
WatchApp/WatchApp Watch App/Pages/ChatView.swift CHANGED
@@ -1,105 +1,212 @@
1
- //
2
- // ContentView.swift
3
- // WatchApp Watch App
4
- //
5
- // Created by Hideki Sato on 6/27/23.
6
- //
7
-
8
  import SwiftUI
9
  import KeychainSwift
10
 
 
 
 
 
 
 
11
  struct ChatView: View {
12
- @Binding var isPresented: Bool
13
  @State private var messages: [ChatMessage] = []
14
- @State private var newMessage = ""
15
- @State private var uuid: String = "956a11be45cba4a4"
 
16
 
17
  var body: some View {
18
  VStack{
19
- Button(action: {
20
- self.isPresented = true
21
- }) {
22
- Image(systemName: "gearshape.fill")
23
- .resizable()
24
- .frame(width: 15, height: 15)
25
- }
26
- .frame(width: 50, height: 30)
27
- .background(Color.clear).buttonStyle(PlainButtonStyle()).padding(.trailing)
28
-
29
- List {
30
- ForEach(messages, id: \.self) { message in
31
- ChatMessageRow(message:message)
32
  }
33
- }.listStyle(PlainListStyle()).padding(.bottom, 10)
34
-
35
-
36
  HStack() {
37
- TextField("Message...", text: $newMessage).frame(width: 120.0, height: 0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  Button(action: {
39
- let keychain = KeychainSwift()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- // Try to get the UUID from the keychain
42
- if keychain.get("uuid") == "" {
43
- let uuid = "956a11be45cba4a4"
44
- keychain.set(uuid, forKey: "uuid")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  }
46
-
47
- let userMessage = ChatMessage(message: newMessage, isUser: true)
48
- messages.append(userMessage)
49
-
50
- // Replace this URL with your server's URL
51
- if let url = URL(string: "https://ttt246-brain.hf.space/sendNotification") {
52
- var request = URLRequest(url: url)
53
- request.httpMethod = "POST" // Change this to any HTTP method you want
54
- request.addValue("application/json", forHTTPHeaderField: "Content-Type") // Add any necessary headers
55
-
56
- let confsData: [String: Any] = [
57
- "openai_key": "",
58
- "pinecone_key": "",
59
- "pinecone_env": "",
60
- "firebase_key": "",
61
- "token":"cI3EvimJQv-G5imdWrBprf:APA91bEZ5u6uq9Yq4a6NglN0L9pVM7p-rlxKB_FikbfKlzHnZT5GeAjxF0deuPT2GurS8bK6JTE2XPZLQqbsrtjxeRGhGOH5INoQ7MrRlr4TR3xFswKxJSkfi1aBUWDaLGALeirZ7GuZ",
62
- "uuid": uuid,
63
- "settings": [
64
- "temperature": 0.6
65
- ]
66
- ]
67
-
68
- let postData: [String: Any] = ["confs": confsData, "message": newMessage]
69
-
70
- do {
71
- let jsonData = try JSONSerialization.data(withJSONObject: postData, options: .prettyPrinted)
72
- URLSession.shared.uploadTask(with: request, from: jsonData) { data, response, error in
73
- guard error == nil, let data = data else {
74
- print("Error: \(error?.localizedDescription ?? "Unknown error")")
75
- return
76
- }
77
-
78
- do {
79
- // Here we are converting data into JSON using JSONSerialization
80
- if let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
81
- if let result = jsonResult["result"] as? [String: Any], let content = result["content"] as? String {
82
- DispatchQueue.main.async {
83
- let serverResponse = ChatMessage(message: content, isUser: false)
84
- messages.append(serverResponse)
85
  }
86
  }
87
  }
88
- } catch {
89
- print("JSONSerialization error: \(error.localizedDescription)")
 
 
 
 
 
 
 
 
 
 
 
90
  }
91
-
92
- }.resume()
93
- } catch {
94
- print("Error: \(error.localizedDescription)")
95
  }
 
 
96
  }
97
- newMessage = ""
98
- }) {
99
- Image(systemName: "paperplane.fill")
100
- }.frame(width: 50.0, height: 35)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
- }.padding().edgesIgnoringSafeArea(.all)
 
103
  }
104
  }
105
 
@@ -107,6 +214,6 @@ struct ChatView: View {
107
 
108
  struct ChatView_Previews: PreviewProvider {
109
  static var previews: some View {
110
- ChatView(isPresented: .constant(false))
111
  }
112
  }
 
 
 
 
 
 
 
 
1
  import SwiftUI
2
  import KeychainSwift
3
 
4
+ struct ContactResponse : Codable {
5
+ let message : [String]
6
+ let result : [Contact]
7
+ let status_code : Int
8
+ }
9
+
10
  struct ChatView: View {
 
11
  @State private var messages: [ChatMessage] = []
12
+ @State private var newMessage: String = ""
13
+ @State private var uuid: String = Constants.DEFAULT_UUID
14
+ @State private var isStarted = false
15
 
16
  var body: some View {
17
  VStack{
18
+ ScrollView {
19
+ LazyVStack(spacing: 0) {
20
+ ForEach(messages, id: \.self) { message in
21
+ ChatMessageRow(chatItem: message)
22
+ }
23
+ }
 
 
 
 
 
 
 
24
  }
25
+ .frame(maxHeight: .infinity).padding(.bottom, 10)
 
 
26
  HStack() {
27
+ Button(action: {}) {
28
+ NavigationLink(destination: SettingView()){
29
+ Image(systemName: "gearshape.fill")
30
+ .font(.system(size: 20))
31
+ .frame(maxWidth: .infinity)
32
+ }
33
+ }.frame(width: 45, height: 45)
34
+ .cornerRadius(5).buttonStyle(PlainButtonStyle())
35
+
36
+ TextField("", text: $newMessage, onEditingChanged: { (isChanged) in
37
+ if isStarted && !isChanged {
38
+ isStarted = false
39
+ print(newMessage)
40
+ }
41
+ }).frame(height: 45)
42
+ .overlay(
43
+ RoundedRectangle(cornerRadius: 6)
44
+ .stroke(Color.white, lineWidth: 1)
45
+ )
46
  Button(action: {
47
+
48
+ sendNotification()
49
+ }) {
50
+ Image(systemName: "paperplane.fill")
51
+ .font(.system(size: 20))
52
+ .frame(maxWidth: .infinity)
53
+ }.frame(width: 45, height: 45)
54
+ .cornerRadius(5)
55
+ }
56
+ }.edgesIgnoringSafeArea(.bottom)
57
+ }
58
+
59
+ func sendNotification() {
60
+ if newMessage == "" {
61
+ return
62
+ }
63
+ // Try to get the UUID from the keychain
64
+ let keychain = KeychainSwift()
65
 
66
+ if keychain.get("uuid") == "" {
67
+ let uuid = "956a11be45cba4a4"
68
+ keychain.set(uuid, forKey: "uuid")
69
+ }
70
+
71
+ // Add sent message to chat list
72
+ let message = ChatMessage(
73
+ type: TypeChat.SEND,
74
+ message: newMessage,
75
+ widgetType: TypeWidget.EMPTY,
76
+ widgetDesc: ""
77
+ )
78
+ messages.append(message)
79
+
80
+ if let url = URL(string: Constants.URL_SEND_NOTIFICATION) {
81
+ var request = URLRequest(url: url)
82
+ request.httpMethod = "POST"
83
+ request.addValue("application/json", forHTTPHeaderField: "Content-Type")
84
+
85
+ let postData: [String: Any] = ["confs": Constants.getConfs(uuid: uuid), "message": newMessage]
86
+
87
+ do {
88
+ let jsonPostData = try JSONSerialization.data(withJSONObject: postData, options: .prettyPrinted)
89
+ URLSession.shared.uploadTask(with: request, from: jsonPostData) { data, response, error in
90
+ guard error == nil, let data = data else {
91
+ print("Error: \(error?.localizedDescription ?? "Unknown error")")
92
+ return
93
  }
94
+
95
+ do {
96
+ if let jsonResult = try JSONSerialization.jsonObject(with: data, options: []) as? [String: Any] {
97
+ if let result = jsonResult["result"] as? [String: Any], let program = result["program"] as? String {
98
+
99
+ /**
100
+ * Analyzed user's query are classified in this switch code.
101
+ * Currently available command types are contact, image and message.
102
+ */
103
+ switch program {
104
+ case Constants.RESPONSE_TYPE_CONTACT:
105
+ if let strList = result["content"] as? String {
106
+ DispatchQueue.main.async {
107
+ let cleanedStr = strList.filter("0123456789,".contains)
108
+ let strArray = cleanedStr.components(separatedBy: ",")
109
+ searchContacts(contactIds: strArray)
110
+ }
111
+ }
112
+
113
+ case Constants.RESPONSE_TYPE_IMAGE:
114
+ if let content = result["content"] as? [String: Any] {
115
+ DispatchQueue.main.async {
116
+ if let imageName = content["image_name"] as? String {
117
+ let message = ChatMessage(
118
+ type: TypeChat.WIDGET,
119
+ message: imageName,
120
+ widgetType: TypeWidget.IMAGE,
121
+ widgetDesc: ""
122
+ )
123
+ messages.append(message)
 
 
 
 
 
 
 
 
 
124
  }
125
  }
126
  }
127
+
128
+ default:
129
+ if let content = result["content"] as? String {
130
+ DispatchQueue.main.async {
131
+ let message = ChatMessage(
132
+ type: TypeChat.RECEIVE,
133
+ message: content,
134
+ widgetType: TypeWidget.EMPTY,
135
+ widgetDesc: ""
136
+ )
137
+ messages.append(message)
138
+ }
139
+ }
140
  }
141
+ }
 
 
 
142
  }
143
+ } catch {
144
+ print("JSONSerialization error: \(error.localizedDescription)")
145
  }
146
+
147
+ }.resume()
148
+ } catch {
149
+ print("Error: \(error.localizedDescription)")
150
+ }
151
+ }
152
+ newMessage = ""
153
+ }
154
+
155
+ func searchContacts(contactIds: Array<String>) {
156
+
157
+ let keychain = KeychainSwift()
158
+
159
+ // Try to get the UUID from the keychain
160
+ if keychain.get("uuid") == "" {
161
+ let uuid = "ac2293beb9f3b1ca"
162
+ keychain.set(uuid, forKey: "uuid")
163
+ }
164
+
165
+ // Send Http request with POST method
166
+ if let url = URL(string: Constants.URL_GET_CONTACTS_BY_IDS) {
167
+ var request = URLRequest(url: url)
168
+ request.httpMethod = "POST"
169
+ request.addValue("application/json", forHTTPHeaderField: "Content-Type")
170
+
171
+ let postData: [String: Any] = ["confs": Constants.getConfs(uuid: uuid), "contactIds": contactIds]
172
+
173
+ do {
174
+ let postJsonData = try JSONSerialization.data(withJSONObject: postData, options: .prettyPrinted)
175
+ URLSession.shared.uploadTask(with: request, from: postJsonData) { data, response, error in
176
+ guard error == nil, let data = data else {
177
+ print("Error: \(error?.localizedDescription ?? "Unknown error")")
178
+ return
179
+ }
180
+
181
+ do {
182
+ let decoder = JSONDecoder()
183
+ let contactResponse = try decoder.decode(ContactResponse.self, from: data)
184
+ let contacts = contactResponse.result
185
+ for contact in contacts {
186
+ do {
187
+ let jsonContact = try JSONEncoder().encode(contact)
188
+ if let strContact = String(data: jsonContact, encoding: .utf8) {
189
+ let message = ChatMessage(
190
+ type: TypeChat.WIDGET,
191
+ message: "",
192
+ widgetType: TypeWidget.CONTACT,
193
+ widgetDesc: strContact
194
+ )
195
+ messages.append(message)
196
+ }
197
+ } catch {
198
+ print("Error converting to JSON string: \(error)")
199
+ }
200
+ }
201
+ } catch {
202
+ print("JSONDecoding error: \(error.localizedDescription)")
203
+ }
204
+ }.resume()
205
+ } catch {
206
+ print("Error: \(error.localizedDescription)")
207
  }
208
+ }
209
+ newMessage = ""
210
  }
211
  }
212
 
 
214
 
215
  struct ChatView_Previews: PreviewProvider {
216
  static var previews: some View {
217
+ ChatView()
218
  }
219
  }
WatchApp/WatchApp Watch App/Pages/ContactView.swift ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import SwiftUI
2
+
3
+ struct ContactView: View {
4
+ @State var contact: Contact
5
+
6
+ var body: some View {
7
+ VStack {
8
+ Text(contact.displayName).padding()
9
+ .bold()
10
+ .foregroundColor(.white)
11
+ .font(.system(size: 18))
12
+ .padding()
13
+ List {
14
+ ForEach(contact.phoneNumbers, id: \.self) { phone in
15
+ Text(phone)
16
+ .foregroundColor(.white)
17
+ .font(.system(size: 15))
18
+ .padding()
19
+ }
20
+ }.listStyle(PlainListStyle()).padding(.bottom, 10)
21
+ }
22
+ }
23
+ }
24
+
25
+ struct ContactView_Previews: PreviewProvider {
26
+ static var previews: some View {
27
+ ContactView(contact: Contact(
28
+ contactId: "5",
29
+ displayName: "Peter Luo",
30
+ phoneNumbers: ["123-234-345"])
31
+ )
32
+ }
33
+ }
WatchApp/WatchApp Watch App/Pages/SettingView.swift CHANGED
@@ -1,16 +1,8 @@
1
- //
2
- // SettingView.swift
3
- // WatchApp Watch App
4
- //
5
- // Created by DarkHorse on 7/1/23.
6
- //
7
-
8
  import SwiftUI
9
  import KeychainSwift
10
 
11
  struct SettingView: View {
12
- @Binding var isPresented: Bool
13
- @State private var uuid: String = "956a11be45cba4a4"
14
 
15
  var body: some View {
16
  VStack {
@@ -23,15 +15,12 @@ struct SettingView: View {
23
  Button(action: {
24
  let keychain = KeychainSwift()
25
  keychain.set("\($uuid)", forKey: "uuid")
26
- self.isPresented = false
27
  }) {
28
- Text("Yes")
29
  }
30
  Spacer()
31
- Button(action: {
32
- self.isPresented = false
33
- }) {
34
- Text("No")
35
  }
36
  Spacer()
37
  }
@@ -41,6 +30,6 @@ struct SettingView: View {
41
 
42
  struct SettingView_Previews: PreviewProvider {
43
  static var previews: some View {
44
- SettingView(isPresented: .constant(true))
45
  }
46
  }
 
 
 
 
 
 
 
 
1
  import SwiftUI
2
  import KeychainSwift
3
 
4
  struct SettingView: View {
5
+ @State private var uuid: String = Constants.DEFAULT_UUID
 
6
 
7
  var body: some View {
8
  VStack {
 
15
  Button(action: {
16
  let keychain = KeychainSwift()
17
  keychain.set("\($uuid)", forKey: "uuid")
 
18
  }) {
19
+ Text("Save")
20
  }
21
  Spacer()
22
+ Button(action: {}) {
23
+ Text("Cancel")
 
 
24
  }
25
  Spacer()
26
  }
 
30
 
31
  struct SettingView_Previews: PreviewProvider {
32
  static var previews: some View {
33
+ SettingView()
34
  }
35
  }
WatchApp/WatchApp Watch App/Values/Constants.swift ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import Foundation
2
+
3
+ struct Constants {
4
+ static let DEFAULT_UUID = "ac2293beb9f3b1ca"
5
+
6
+ static let BASE_URL = "https://ttt246-brain.hf.space/"
7
+ static let URL_SEND_NOTIFICATION = BASE_URL + "sendNotification"
8
+ static let URL_GET_CONTACTS_BY_IDS = BASE_URL + "contacts/get_by_ids"
9
+
10
+ static let RESPONSE_TYPE_CONTACT = "contact"
11
+ static let RESPONSE_TYPE_IMAGE = "image"
12
+
13
+ static func getConfs(uuid: String) -> [String: Any] {
14
+ return [
15
+ "openai_key": "",
16
+ "pinecone_key": "",
17
+ "pinecone_env": "",
18
+ "firebase_key": "",
19
+ "token":"cI3EvimJQv-G5imdWrBprf:APA91bEZ5u6uq9Yq4a6NglN0L9pVM7p-rlxKB_FikbfKlzHnZT5GeAjxF0deuPT2GurS8bK6JTE2XPZLQqbsrtjxeRGhGOH5INoQ7MrRlr4TR3xFswKxJSkfi1aBUWDaLGALeirZ7GuZ",
20
+ "uuid": uuid,
21
+ "settings": [
22
+ "temperature": 0.6
23
+ ]
24
+ ]
25
+ }
26
+ }
27
+
WatchApp/WatchApp Watch App/Values/File.swift ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // File.swift
3
+ // WatchApp Watch App
4
+ //
5
+ // Created by DarkHorse on 7/9/23.
6
+ //
7
+
8
+ import Foundation
WatchApp/WatchApp Watch App/Values/Strings.swift ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ import SwiftUI
2
+
3
+ struct String {
4
+ static let app: String = CGSt("RisingWatch")
5
+ }
WatchApp/WatchApp.xcodeproj/project.pbxproj CHANGED
@@ -17,6 +17,10 @@
17
  FE673FCE2A5022C9003EF230 /* ChatMessageRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */; };
18
  FE673FD02A504903003EF230 /* SettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FCF2A504903003EF230 /* SettingView.swift */; };
19
  FE673FD32A504EAF003EF230 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FD22A504EAF003EF230 /* MainView.swift */; };
 
 
 
 
20
  /* End PBXBuildFile section */
21
 
22
  /* Begin PBXContainerItemProxy section */
@@ -70,6 +74,10 @@
70
  FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageRow.swift; sourceTree = "<group>"; };
71
  FE673FCF2A504903003EF230 /* SettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingView.swift; sourceTree = "<group>"; };
72
  FE673FD22A504EAF003EF230 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
 
 
 
 
73
  /* End PBXFileReference section */
74
 
75
  /* Begin PBXFrameworksBuildPhase section */
@@ -122,6 +130,7 @@
122
  FE56FAE52A4C5810008410B4 /* WatchApp Watch App */ = {
123
  isa = PBXGroup;
124
  children = (
 
125
  FE673FCC2A502280003EF230 /* Components */,
126
  FE673FD12A504913003EF230 /* Pages */,
127
  FE673FD22A504EAF003EF230 /* MainView.swift */,
@@ -151,6 +160,8 @@
151
  isa = PBXGroup;
152
  children = (
153
  FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */,
 
 
154
  );
155
  path = Components;
156
  sourceTree = "<group>";
@@ -160,10 +171,19 @@
160
  children = (
161
  FE673FCF2A504903003EF230 /* SettingView.swift */,
162
  FE56FAE82A4C5810008410B4 /* ChatView.swift */,
 
163
  );
164
  path = Pages;
165
  sourceTree = "<group>";
166
  };
 
 
 
 
 
 
 
 
167
  /* End PBXGroup section */
168
 
169
  /* Begin PBXNativeTarget section */
@@ -326,10 +346,14 @@
326
  isa = PBXSourcesBuildPhase;
327
  buildActionMask = 2147483647;
328
  files = (
 
 
329
  FE673FCE2A5022C9003EF230 /* ChatMessageRow.swift in Sources */,
 
330
  FE673FD02A504903003EF230 /* SettingView.swift in Sources */,
331
  FE56FB142A4C80A5008410B4 /* ChatView.swift in Sources */,
332
  FE673FD32A504EAF003EF230 /* MainView.swift in Sources */,
 
333
  FE56FAE72A4C5810008410B4 /* WatchAppApp.swift in Sources */,
334
  );
335
  runOnlyForDeploymentPostprocessing = 0;
@@ -484,7 +508,6 @@
484
  FE56FB082A4C5814008410B4 /* Debug */ = {
485
  isa = XCBuildConfiguration;
486
  buildSettings = {
487
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
488
  ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
489
  CODE_SIGN_STYLE = Automatic;
490
  CURRENT_PROJECT_VERSION = 1;
@@ -513,7 +536,6 @@
513
  FE56FB092A4C5814008410B4 /* Release */ = {
514
  isa = XCBuildConfiguration;
515
  buildSettings = {
516
- ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
517
  ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
518
  CODE_SIGN_STYLE = Automatic;
519
  CURRENT_PROJECT_VERSION = 1;
 
17
  FE673FCE2A5022C9003EF230 /* ChatMessageRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */; };
18
  FE673FD02A504903003EF230 /* SettingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FCF2A504903003EF230 /* SettingView.swift */; };
19
  FE673FD32A504EAF003EF230 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FD22A504EAF003EF230 /* MainView.swift */; };
20
+ FE673FD52A5413F5003EF230 /* ContactView.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE673FD42A5413F5003EF230 /* ContactView.swift */; };
21
+ FE8CB8F52A5B0F5F002CBC44 /* ImageRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8CB8F42A5B0F5F002CBC44 /* ImageRow.swift */; };
22
+ FE8CB8F72A5BD51A002CBC44 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE8CB8F62A5BD51A002CBC44 /* Constants.swift */; };
23
+ FED5B74B2A5833E30040DF09 /* ContactRow.swift in Sources */ = {isa = PBXBuildFile; fileRef = FED5B74A2A5833E20040DF09 /* ContactRow.swift */; };
24
  /* End PBXBuildFile section */
25
 
26
  /* Begin PBXContainerItemProxy section */
 
74
  FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatMessageRow.swift; sourceTree = "<group>"; };
75
  FE673FCF2A504903003EF230 /* SettingView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingView.swift; sourceTree = "<group>"; };
76
  FE673FD22A504EAF003EF230 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
77
+ FE673FD42A5413F5003EF230 /* ContactView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactView.swift; sourceTree = "<group>"; };
78
+ FE8CB8F42A5B0F5F002CBC44 /* ImageRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageRow.swift; sourceTree = "<group>"; };
79
+ FE8CB8F62A5BD51A002CBC44 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
80
+ FED5B74A2A5833E20040DF09 /* ContactRow.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContactRow.swift; sourceTree = "<group>"; };
81
  /* End PBXFileReference section */
82
 
83
  /* Begin PBXFrameworksBuildPhase section */
 
130
  FE56FAE52A4C5810008410B4 /* WatchApp Watch App */ = {
131
  isa = PBXGroup;
132
  children = (
133
+ FE8CB8EB2A5AFFCF002CBC44 /* Values */,
134
  FE673FCC2A502280003EF230 /* Components */,
135
  FE673FD12A504913003EF230 /* Pages */,
136
  FE673FD22A504EAF003EF230 /* MainView.swift */,
 
160
  isa = PBXGroup;
161
  children = (
162
  FE673FCD2A5022C9003EF230 /* ChatMessageRow.swift */,
163
+ FED5B74A2A5833E20040DF09 /* ContactRow.swift */,
164
+ FE8CB8F42A5B0F5F002CBC44 /* ImageRow.swift */,
165
  );
166
  path = Components;
167
  sourceTree = "<group>";
 
171
  children = (
172
  FE673FCF2A504903003EF230 /* SettingView.swift */,
173
  FE56FAE82A4C5810008410B4 /* ChatView.swift */,
174
+ FE673FD42A5413F5003EF230 /* ContactView.swift */,
175
  );
176
  path = Pages;
177
  sourceTree = "<group>";
178
  };
179
+ FE8CB8EB2A5AFFCF002CBC44 /* Values */ = {
180
+ isa = PBXGroup;
181
+ children = (
182
+ FE8CB8F62A5BD51A002CBC44 /* Constants.swift */,
183
+ );
184
+ path = Values;
185
+ sourceTree = "<group>";
186
+ };
187
  /* End PBXGroup section */
188
 
189
  /* Begin PBXNativeTarget section */
 
346
  isa = PBXSourcesBuildPhase;
347
  buildActionMask = 2147483647;
348
  files = (
349
+ FE8CB8F52A5B0F5F002CBC44 /* ImageRow.swift in Sources */,
350
+ FE8CB8F72A5BD51A002CBC44 /* Constants.swift in Sources */,
351
  FE673FCE2A5022C9003EF230 /* ChatMessageRow.swift in Sources */,
352
+ FE673FD52A5413F5003EF230 /* ContactView.swift in Sources */,
353
  FE673FD02A504903003EF230 /* SettingView.swift in Sources */,
354
  FE56FB142A4C80A5008410B4 /* ChatView.swift in Sources */,
355
  FE673FD32A504EAF003EF230 /* MainView.swift in Sources */,
356
+ FED5B74B2A5833E30040DF09 /* ContactRow.swift in Sources */,
357
  FE56FAE72A4C5810008410B4 /* WatchAppApp.swift in Sources */,
358
  );
359
  runOnlyForDeploymentPostprocessing = 0;
 
508
  FE56FB082A4C5814008410B4 /* Debug */ = {
509
  isa = XCBuildConfiguration;
510
  buildSettings = {
 
511
  ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
512
  CODE_SIGN_STYLE = Automatic;
513
  CURRENT_PROJECT_VERSION = 1;
 
536
  FE56FB092A4C5814008410B4 /* Release */ = {
537
  isa = XCBuildConfiguration;
538
  buildSettings = {
 
539
  ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
540
  CODE_SIGN_STYLE = Automatic;
541
  CURRENT_PROJECT_VERSION = 1;
WatchApp/WatchApp.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict/>
5
+ </plist>
WatchApp/WatchApp.xcodeproj/project.xcworkspace/xcuserdata/darkhorse.xcuserdatad/UserInterfaceState.xcuserstate CHANGED
Binary files a/WatchApp/WatchApp.xcodeproj/project.xcworkspace/xcuserdata/darkhorse.xcuserdatad/UserInterfaceState.xcuserstate and b/WatchApp/WatchApp.xcodeproj/project.xcworkspace/xcuserdata/darkhorse.xcuserdatad/UserInterfaceState.xcuserstate differ
 
WatchApp/WatchApp.xcodeproj/project.xcworkspace/xcuserdata/darkhorse.xcuserdatad/WorkspaceSettings.xcsettings ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>BuildLocationStyle</key>
6
+ <string>UseAppPreferences</string>
7
+ <key>CustomBuildLocationType</key>
8
+ <string>RelativeToDerivedData</string>
9
+ <key>DerivedDataLocationStyle</key>
10
+ <string>Default</string>
11
+ <key>ShowSharedSchemesAutomaticallyEnabled</key>
12
+ <true/>
13
+ </dict>
14
+ </plist>
WatchApp/WatchApp.xcodeproj/xcuserdata/darkhorse.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist CHANGED
@@ -3,4 +3,22 @@
3
  uuid = "78398B09-67A6-447A-BDF1-6FF7D60370C3"
4
  type = "1"
5
  version = "2.0">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
  </Bucket>
 
3
  uuid = "78398B09-67A6-447A-BDF1-6FF7D60370C3"
4
  type = "1"
5
  version = "2.0">
6
+ <Breakpoints>
7
+ <BreakpointProxy
8
+ BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
9
+ <BreakpointContent
10
+ uuid = "CD74F7A6-629E-4D64-B2EF-98510C1B484E"
11
+ shouldBeEnabled = "Yes"
12
+ ignoreCount = "0"
13
+ continueAfterRunningActions = "No"
14
+ filePath = "WatchApp Watch App/MainView.swift"
15
+ startingColumnNumber = "9223372036854775807"
16
+ endingColumnNumber = "9223372036854775807"
17
+ startingLineNumber = "13"
18
+ endingLineNumber = "13"
19
+ landmarkName = "previews"
20
+ landmarkType = "24">
21
+ </BreakpointContent>
22
+ </BreakpointProxy>
23
+ </Breakpoints>
24
  </Bucket>
WatchApp/WatchApp.xcodeproj/xcuserdata/darkhorse.xcuserdatad/xcschemes/xcschememanagement.plist CHANGED
@@ -4,6 +4,69 @@
4
  <dict>
5
  <key>SchemeUserState</key>
6
  <dict>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
  <key>WatchApp Watch App.xcscheme_^#shared#^_</key>
8
  <dict>
9
  <key>orderHint</key>
 
4
  <dict>
5
  <key>SchemeUserState</key>
6
  <dict>
7
+ <key>Promises (Playground) 1.xcscheme</key>
8
+ <dict>
9
+ <key>isShown</key>
10
+ <false/>
11
+ <key>orderHint</key>
12
+ <integer>3</integer>
13
+ </dict>
14
+ <key>Promises (Playground) 2.xcscheme</key>
15
+ <dict>
16
+ <key>isShown</key>
17
+ <false/>
18
+ <key>orderHint</key>
19
+ <integer>4</integer>
20
+ </dict>
21
+ <key>Promises (Playground) 3.xcscheme</key>
22
+ <dict>
23
+ <key>isShown</key>
24
+ <false/>
25
+ <key>orderHint</key>
26
+ <integer>5</integer>
27
+ </dict>
28
+ <key>Promises (Playground) 4.xcscheme</key>
29
+ <dict>
30
+ <key>isShown</key>
31
+ <false/>
32
+ <key>orderHint</key>
33
+ <integer>6</integer>
34
+ </dict>
35
+ <key>Promises (Playground) 5.xcscheme</key>
36
+ <dict>
37
+ <key>isShown</key>
38
+ <false/>
39
+ <key>orderHint</key>
40
+ <integer>7</integer>
41
+ </dict>
42
+ <key>Promises (Playground) 6.xcscheme</key>
43
+ <dict>
44
+ <key>isShown</key>
45
+ <false/>
46
+ <key>orderHint</key>
47
+ <integer>2</integer>
48
+ </dict>
49
+ <key>Promises (Playground) 7.xcscheme</key>
50
+ <dict>
51
+ <key>isShown</key>
52
+ <false/>
53
+ <key>orderHint</key>
54
+ <integer>8</integer>
55
+ </dict>
56
+ <key>Promises (Playground) 8.xcscheme</key>
57
+ <dict>
58
+ <key>isShown</key>
59
+ <false/>
60
+ <key>orderHint</key>
61
+ <integer>9</integer>
62
+ </dict>
63
+ <key>Promises (Playground).xcscheme</key>
64
+ <dict>
65
+ <key>isShown</key>
66
+ <false/>
67
+ <key>orderHint</key>
68
+ <integer>0</integer>
69
+ </dict>
70
  <key>WatchApp Watch App.xcscheme_^#shared#^_</key>
71
  <dict>
72
  <key>orderHint</key>