GeezerVison is showing github.com — feat(mobile): add offline iPhone voice input by t3dotgg · Pull Request #8614 · pingdotgg/t3code
feat(mobile): add offline iPhone voice input
#8614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.json
(2)
.md
(4)
.patch
(2)
.swift
(2)
.ts
(16)
.tsx
(8)
.yaml
(2)
All 7 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -295,6 +295,15 @@ const config: ExpoConfig = {
},
},
],
[
"expo-audio",
{
microphonePermission: "Allow T3 Code to use your microphone for voice input.",
recordAudioAndroid: false,
enableBackgroundPlayback: false,
enableBackgroundRecording: false,
},
],
[
"expo-camera",
{
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -29,6 +29,9 @@ public class T3ComposerEditorModule: Module {
Prop("editable") { (view: T3ComposerEditorView, editable: Bool) in
view.setEditable(editable)
}
Prop("readOnly") { (view: T3ComposerEditorView, readOnly: Bool) in
view.setReadOnly(readOnly)
}
Prop("scrollEnabled") { (view: T3ComposerEditorView, scrollEnabled: Bool) in
view.setScrollEnabled(scrollEnabled)
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -60,10 +60,21 @@ private final class ComposerTextAttachment: NSTextAttachment {
private final class ComposerTextView: UITextView {
private static let pastedImageDirectoryName = "t3-composer-paste"
private static let stalePastedImageAge: TimeInterval = 60 * 60
private static let readOnlyActions = Set([
"cut:",
"delete:",
"paste:",
"redo:",
"toggleBoldface:",
"toggleItalics:",
"toggleUnderline:",
"undo:",
])
var onPasteImages: (([String]) -> Void)?
var onAttributedMutation: (() -> Void)?
var onSubmit: (() -> Void)?
var isReadOnly = false
override var keyCommands: [UIKeyCommand]? {
var commands = super.keyCommands ?? []
Expand All
@@ -83,6 +94,9 @@ private final class ComposerTextView: UITextView {
}
override func canPerformAction(_ action: Selector, withSender sender: Any?) -> Bool {
if isReadOnly && Self.readOnlyActions.contains(NSStringFromSelector(action)) {
return false
}
if action == #selector(paste(_:)) {
let pasteboard = UIPasteboard.general
if pasteboard.hasImages ||
Expand All
@@ -96,6 +110,9 @@ private final class ComposerTextView: UITextView {
}
override func paste(_ sender: Any?) {
guard !isReadOnly else {
return
}
let pasteboard = UIPasteboard.general
let imageProviders = pasteboard.itemProviders.filter {
$0.canLoadObject(ofClass: UIImage.self)
Expand All
@@ -117,6 +134,9 @@ private final class ComposerTextView: UITextView {
}
override func deleteBackward() {
guard !isReadOnly else {
return
}
guard selectedRange.length == 0, selectedRange.location > 0 else {
super.deleteBackward()
return
Expand Down
Expand Up
@@ -160,9 +180,12 @@ private final class ComposerTextView: UITextView {
}
group.notify(queue: .main) { [weak self] in
guard let self, !self.isReadOnly else {
return
}
let urls = images.compactMap { $0 }.compactMap(Self.writeTemporaryImage)
if !urls.isEmpty {
self? .onPasteImages?(urls)
self.onPasteImages?(urls)
}
}
}
Expand All
@@ -175,6 +198,9 @@ private final class ComposerTextView: UITextView {
}
override func cut(_ sender: Any?) {
guard !isReadOnly else {
return
}
guard isEditable, selectedRange.length > 0 else {
return super.cut(sender)
}
Expand Down
Expand Up
@@ -306,6 +332,7 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
private var contentInsetVertical: CGFloat = 0
private var shouldAutoFocus = false
private var didAutoFocus = false
private var isReadOnly = false
private var isApplyingControlledValue = false
private var nativeEventCount = 0
private var lastContentSize = CGSize.zero
Expand Down
Expand Up
@@ -451,6 +478,11 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
textView.isEditable = editable
}
func setReadOnly(_ readOnly: Bool) {
isReadOnly = readOnly
textView.isReadOnly = readOnly
}
func setScrollEnabled(_ scrollEnabled: Bool) {
textView.isScrollEnabled = scrollEnabled
}
Expand Down
Expand Up
@@ -504,13 +536,16 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
replacementText text: String
) -> Bool {
restoreBaseTypingAttributes()
return true
return !isReadOnly
}
public func textDroppableView(
_ textDroppableView: UIView & UITextDroppable,
proposalForDrop drop: UITextDropRequest
) -> UITextDropProposal {
guard !isReadOnly else {
return UITextDropProposal(operation: .cancel)
}
guard droppedImageProviders(in: drop) != nil else {
return drop.suggestedProposal
}
Expand All
@@ -527,6 +562,9 @@ public final class T3ComposerEditorView: ExpoView, UITextViewDelegate, UITextDro
_ textDroppableView: UIView & UITextDroppable,
willPerformDrop drop: UITextDropRequest
) {
guard !isReadOnly else {
return
}
guard let imageProviders = droppedImageProviders(in: drop) else {
return
}
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -55,6 +55,7 @@
"@noble/curves": "catalog:",
"@noble/hashes": "catalog:",
"@pierre/diffs": "catalog:",
"@react-native-ai/apple": "0.12.0",
"@react-native-menu/menu": "^2.0.0",
"@react-navigation/elements": "2.9.26",
"@react-navigation/native": "7.3.4",
Expand All
@@ -75,6 +76,7 @@
"effect": "catalog:",
"expo": "~57.0.18",
"expo-asset": "~57.0.15",
"expo-audio": "~57.0.4",
"expo-auth-session": "~57.0.10",
"expo-blur": "~57.0.2",
"expo-build-properties": "~57.0.15",
Expand Down
Expand Up
@@ -143,7 +145,8 @@
"autolinking": {
"buildFromSource": [
"react-native-screens",
"@react-native-menu/menu"
"@react-native-menu/menu",
"expo-audio"
]
}
},
Expand Down
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
import { GlassView, isGlassEffectAPIAvailable } from "expo-glass-effect";
import type { ReactNode } from "react";
import type { ReactNode, Ref } from "react";
import {
Platform,
useColorScheme,
Expand All
@@ -20,6 +20,7 @@ const ThemedGlassView = withUniwind(GlassView, {
});
interface GlassSurfaceProps extends ViewProps {
readonly ref?: Ref<View>;
readonly children: ReactNode;
readonly glassEffectStyle?: "clear" | "regular" | "none";
readonly tintColor?: ColorValue;
Expand All
@@ -32,6 +33,7 @@ interface GlassSurfaceProps extends ViewProps {
}
export function GlassSurface({
ref,
children,
glassEffectStyle = "regular",
chrome = "default",
Expand Down
Expand Up
@@ -68,6 +70,7 @@ export function GlassSurface({
return (
<ThemedGlassView
{...props}
ref={ref}
className={cn(
chrome === "none"
? "border-0 border-transparent bg-transparent"
Expand All
@@ -90,6 +93,7 @@ export function GlassSurface({
return (
<View
{...props}
ref={ref}
className={cn(
chrome === "none"
? "border-0 border-transparent bg-transparent"
Expand Down
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Loading
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.