-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update GenAI API and implement folder picker UI
- Loading branch information
Showing
5 changed files
with
222 additions
and
148 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
mobile/examples/phi-3/ios/LocalLLM/LocalLLM/FolderPicker.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
import SwiftUI | ||
import UIKit | ||
|
||
struct FolderPicker: UIViewControllerRepresentable { | ||
var onPick: (URL?) -> Void | ||
|
||
func makeUIViewController(context: Context) -> UIDocumentPickerViewController { | ||
let picker = UIDocumentPickerViewController(forOpeningContentTypes: [.folder]) | ||
picker.allowsMultipleSelection = false | ||
picker.delegate = context.coordinator | ||
return picker | ||
} | ||
|
||
func updateUIViewController(_ uiViewController: UIDocumentPickerViewController, context: Context) {} | ||
|
||
func makeCoordinator() -> Coordinator { | ||
Coordinator(onPick: onPick) | ||
} | ||
|
||
class Coordinator: NSObject, UIDocumentPickerDelegate { | ||
let onPick: (URL?) -> Void | ||
|
||
init(onPick: @escaping (URL?) -> Void) { | ||
self.onPick = onPick | ||
} | ||
|
||
func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) { | ||
onPick(urls.first) | ||
} | ||
|
||
func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) { | ||
onPick(nil) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.