Skip to content

Commit

Permalink
refactor: moved constants out of /apps due to expo router path resolu…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
Vali-98 committed Nov 29, 2024
1 parent 70c34d3 commit cad89d7
Show file tree
Hide file tree
Showing 123 changed files with 249 additions and 276 deletions.
29 changes: 13 additions & 16 deletions app/APIMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
import {
KAI,
Horde,
TGWUI,
Mancer,
TextCompletions,
OpenRouter,
OpenAI,
Ollama,
Claude,
ChatCompletions,
Cohere,
} from '@components/Endpoint'
import ChatCompletions from '@components/Endpoint/ChatCompletions'
import Claude from '@components/Endpoint/Claude'
import Cohere from '@components/Endpoint/Cohere'
import Horde from '@components/Endpoint/Horde'
import KAI from '@components/Endpoint/KAI'
import Mancer from '@components/Endpoint/Mancer'
import Ollama from '@components/Endpoint/Ollama'
import OpenAI from '@components/Endpoint/OpenAI'
import OpenRouter from '@components/Endpoint/OpenRouter'
import TGWUI from '@components/Endpoint/TGWUI'
import TextCompletions from '@components/Endpoint/TextCompletions'
import FadeDownView from '@components/FadeDownView'
import { Global, API, Style } from '@globals'
import { API, Global, Style } from 'constants/Global'
import { Stack } from 'expo-router'
import { useEffect } from 'react'
import { SafeAreaView, Text, StyleSheet, View, ScrollView } from 'react-native'
import { SafeAreaView, ScrollView, StyleSheet, Text, View } from 'react-native'
import { Dropdown } from 'react-native-element-dropdown'
import { useMMKVString } from 'react-native-mmkv'

Expand Down
6 changes: 3 additions & 3 deletions app/About.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import SupportButton from '@components/SupportButton'
import { AppSettings } from '@constants/GlobalValues'
import { FontAwesome } from '@expo/vector-icons'
import { Logger, Style } from '@globals'
import appConfig from 'app.config'
import { Logger, Style } from 'constants/Global'
import { AppSettings } from 'constants/GlobalValues'
import { Stack } from 'expo-router'
import React, { useState } from 'react'
import { View, Image, Text, StyleSheet, Linking, TouchableOpacity } from 'react-native'
import { Image, Linking, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import { useMMKVBoolean } from 'react-native-mmkv'

const About = () => {
Expand Down
15 changes: 4 additions & 11 deletions app/AppSettingsMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
import Alert from '@components/Alert'
import SectionTitle from '@components/SectionTitle'
import SwitchWithDescription from '@components/SwitchWithDescription'
import { registerForPushNotificationsAsync } from '@constants/Notifications'
import {
Style,
AppSettings,
Logger,
Characters,
unlockScreenOrientation,
lockScreenOrientation,
} from '@globals'
import appConfig from 'app.config'
import { AppSettings, Characters, Logger, Style } from 'constants/Global'
import { registerForPushNotificationsAsync } from 'constants/Notifications'
import { copyFile, DocumentDirectoryPath, DownloadDirectoryPath } from 'cui-fs'
import { reloadAppAsync } from 'expo'
import { getDocumentAsync } from 'expo-document-picker'
import { documentDirectory, copyAsync, deleteAsync } from 'expo-file-system'
import { copyAsync, deleteAsync, documentDirectory } from 'expo-file-system'
import { Stack, useRouter } from 'expo-router'
import React from 'react'
import { StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native'
import { ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import { useMMKVBoolean } from 'react-native-mmkv'

const appVersion = appConfig.expo.version
Expand Down
2 changes: 1 addition & 1 deletion app/BookInfo/Entry.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import CheckboxTitle from '@components/CheckboxTitle'
import SliderItem from '@components/SliderItem'
import { FontAwesome } from '@expo/vector-icons'
import { Style, Logger } from '@globals'
import { Style, Logger } from 'constants/Global'
import { useState, useRef } from 'react'
import { Text, View, TouchableOpacity, TextInput, StyleSheet } from 'react-native'
import Collapsible from 'react-native-collapsible'
Expand Down
4 changes: 2 additions & 2 deletions app/BookInfo/[bookName].js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Style } from '@globals'
import { Style } from 'constants/Global'
import { FlashList } from '@shopify/flash-list'
import { Lorebooks } from 'app/constants/Lorebooks'
import { Lorebooks } from 'constants/Lorebooks'
import { Stack, useLocalSearchParams } from 'expo-router'
import React, { useEffect, useState } from 'react'
import { StyleSheet, View } from 'react-native'
Expand Down
10 changes: 5 additions & 5 deletions app/CharacterEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import Avatar from '@components/Avatar'
import AvatarViewer from '@components/ChatMenu/ChatWindow/AvatarViewer'
import FadeDownView from '@components/FadeDownView'
import PopupMenu from '@components/PopupMenu'
import { useViewerState } from '@constants/AvatarViewer'
import { AntDesign } from '@expo/vector-icons'
import { Characters, Chats, Logger, Style } from '@globals'
import { CharacterCardData } from 'app/constants/Characters'
import { Tokenizer } from 'app/constants/Tokenizer'
import { useViewerState } from 'constants/AvatarViewer'
import { CharacterCardData } from 'constants/Characters'
import { Characters, Chats, Logger, Style } from 'constants/Global'
import { Tokenizer } from 'constants/Tokenizer'
import * as DocumentPicker from 'expo-document-picker'
import { Stack, useNavigation, useRouter } from 'expo-router'
import { useEffect, useRef, useState } from 'react'
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'
import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'
import { useShallow } from 'zustand/react/shallow'

const ChracterEditor = () => {
Expand Down
6 changes: 3 additions & 3 deletions app/ColorSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { AppSettings } from '@constants/GlobalValues'
import { FontAwesome } from '@expo/vector-icons'
import Slider from '@react-native-community/slider'
import { ColorId, Style } from 'app/constants/Style'
import { AppSettings } from 'constants/GlobalValues'
import { ColorId, Style } from 'constants/Style'
import { reloadAppAsync } from 'expo'
import { Stack } from 'expo-router'
import { useState } from 'react'
import { View, Text, TouchableOpacity, Switch, ScrollView, Pressable } from 'react-native'
import { Pressable, ScrollView, Switch, Text, TouchableOpacity, View } from 'react-native'
import { useMMKVBoolean } from 'react-native-mmkv'

const ColorSettings = () => {
Expand Down
12 changes: 6 additions & 6 deletions app/Instruct.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import SliderItem from '@components/SliderItem'
import StringArrayEditor from '@components/StringArrayEditor'
import TextBox from '@components/TextBox'
import TextBoxModal from '@components/TextBoxModal'
import useAutosave from '@constants/AutoSave'
import { FontAwesome } from '@expo/vector-icons'
import { Instructs, Logger, MarkdownStyle, Style, saveStringToDownload } from '@globals'
import useAutosave from 'constants/AutoSave'
import { Instructs, Logger, MarkdownStyle, Style, saveStringToDownload } from 'constants/Global'
import { useLiveQuery } from 'drizzle-orm/expo-sqlite'
import { Stack } from 'expo-router'
import { useState } from 'react'
import {
View,
Pressable,
SafeAreaView,
TouchableOpacity,
StyleSheet,
ScrollView,
StyleSheet,
Text,
Pressable,
TouchableOpacity,
View,
} from 'react-native'
import { Dropdown } from 'react-native-element-dropdown'
import Markdown from 'react-native-markdown-display'
Expand Down
2 changes: 1 addition & 1 deletion app/Logs.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Alert from '@components/Alert'
import FadeDownView from '@components/FadeDownView'
import { FontAwesome } from '@expo/vector-icons'
import { Global, Logger, Style, saveStringToDownload } from '@globals'
import { FlashList } from '@shopify/flash-list'
import { Global, Logger, Style, saveStringToDownload } from 'constants/Global'
import { Stack } from 'expo-router'
import { Pressable, StyleSheet, Text, View } from 'react-native'
import { useMMKVObject } from 'react-native-mmkv'
Expand Down
4 changes: 2 additions & 2 deletions app/LorebookMenu.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import TextBoxModal from 'app/components/TextBoxModal'
import { Lorebooks } from 'app/constants/Lorebooks'
import { Lorebooks } from 'constants/Lorebooks'
import { FontAwesome } from '@expo/vector-icons'
import { Stack, useRouter } from 'expo-router'
import { Style } from '@globals'
import { Style } from 'constants/Global'
import React, { useEffect, useState } from 'react'
import { View, Text, StyleSheet, TouchableOpacity, ScrollView, TextInput } from 'react-native'

Expand Down
30 changes: 19 additions & 11 deletions app/SamplerMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import Alert from '@components/Alert'
import CheckboxTitle from '@components/CheckboxTitle'
import FadeDownView from '@components/FadeDownView'
import { defaultTemplates } from '@constants/API/DefaultAPI'
import { AppMode, AppSettings } from '@constants/GlobalValues'
import SliderItem from '@components/SliderItem'
import TextBox from '@components/TextBox'
import TextBoxModal from '@components/TextBoxModal'
import { FontAwesome } from '@expo/vector-icons'
import { API, Global, Logger, Presets, saveStringExternal, Style } from '@globals'
import { APIState as APIStateNew } from 'app/constants/API/APIManagerState'
import { APIState } from 'app/constants/APIState'
import { SamplerPreset, Samplers } from 'app/constants/SamplerData'
import { APIState as APIStateNew } from 'constants/API/APIManagerState'
import { APIState } from 'constants/APIState'
import { API, Global, Logger, Presets, saveStringToDownload, Style } from 'constants/Global'
import { AppMode, AppSettings } from 'constants/GlobalValues'
import { SamplerPreset, Samplers } from 'constants/SamplerData'
import { Stack } from 'expo-router'
import { useEffect, useState } from 'react'
import { SafeAreaView, ScrollView, StyleSheet, Text, TouchableOpacity, View } from 'react-native'
import { Dropdown } from 'react-native-element-dropdown'
import { useMMKVBoolean, useMMKVObject, useMMKVString } from 'react-native-mmkv'

import { CheckboxTitle, SliderItem, TextBox, TextBoxModal } from './components'

type PresetLabel = {
label: string
}
Expand Down Expand Up @@ -48,9 +49,10 @@ const SamplerMenu = () => {
}, [])

const [legacy, setLegacy] = useMMKVBoolean(AppSettings.UseLegacyAPI)
const { apiValues, activeIndex } = APIStateNew.useAPIState((state) => ({
const { apiValues, activeIndex, getTemplates } = APIStateNew.useAPIState((state) => ({
apiValues: state.values,
activeIndex: state.activeIndex,
getTemplates: state.getTemplates,
}))

const samplerList =
Expand All @@ -59,7 +61,7 @@ const SamplerMenu = () => {
: legacy
? APIState[APIType as API].samplers
: activeIndex !== -1
? defaultTemplates.find((item) => item.name === apiValues[activeIndex].configName)
? getTemplates().find((item) => item.name === apiValues[activeIndex].configName)
?.request.samplerFields
: []

Expand Down Expand Up @@ -182,7 +184,13 @@ const SamplerMenu = () => {
<TouchableOpacity
style={styles.button}
onPress={async () => {
saveStringExternal(`${presetName}.json`, JSON.stringify(currentPreset))
saveStringToDownload(
JSON.stringify(currentPreset),
`${presetName}.json`,
'utf8'
).then(() => {
Logger.log('Downloaded Sampler Preset!')
})
}}>
<FontAwesome
size={24}
Expand Down
2 changes: 1 addition & 1 deletion app/TTSMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import FadeDownView from '@components/FadeDownView'
import { FontAwesome } from '@expo/vector-icons'
import { Global, Logger, Style } from '@globals'
import { Global, Logger, Style } from 'constants/Global'
import { Stack } from 'expo-router'
import * as Speech from 'expo-speech'
import { useEffect, useState } from 'react'
Expand Down
16 changes: 5 additions & 11 deletions app/components/APIManager/APIValueItem.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import Alert from '@components/Alert'
import SwitchComponent from '@components/SwitchTitle'
import { APIManagerValue, APIState } from '@constants/API/APIManagerState'
import { AntDesign } from '@expo/vector-icons'
import { Style } from '@globals'
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'
import Animated, {
interpolateColor,
useAnimatedStyle,
useSharedValue,
withTiming,
} from 'react-native-reanimated'
import { APIManagerValue, APIState } from 'constants/API/APIManagerState'
import { Style } from 'constants/Global'
import { StyleSheet, Text, TouchableOpacity, View } from 'react-native'

type APIValueItemProps = {
item: APIManagerValue
Expand Down Expand Up @@ -40,7 +34,7 @@ const APIValueItem: React.FC<APIValueItemProps> = ({ item, index }) => {
}

return (
<Animated.View style={item.active ? styles.longContainer : styles.longContainerInactive}>
<View style={item.active ? styles.longContainer : styles.longContainerInactive}>
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
<SwitchComponent
value={item.active}
Expand Down Expand Up @@ -70,7 +64,7 @@ const APIValueItem: React.FC<APIValueItemProps> = ({ item, index }) => {
<AntDesign name="edit" color={Style.getColor('primary-text1')} size={24} />
</TouchableOpacity>
</View>
</Animated.View>
</View>
)
}

Expand Down
14 changes: 8 additions & 6 deletions app/components/APIManager/AddAPI.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import ButtonPrimary from '@components/Buttons/ButtonPrimary'
import { APIManagerValue, APIState } from '@constants/API/APIManagerState'
import claudeModels from '@constants/API/ClaudeModels.json'
import { defaultTemplates } from '@constants/API/DefaultAPI'
import { MaterialIcons } from '@expo/vector-icons'
import { Logger, Style } from '@globals'
import { APIManagerValue, APIState } from 'constants/API/APIManagerState'
import { Logger, Style } from 'constants/Global'
import { Stack, useRouter } from 'expo-router'
import { useEffect, useState } from 'react'
import { ScrollView, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native'
Expand All @@ -25,9 +24,12 @@ export interface APIValues {

const AddAPI = () => {
const router = useRouter()
const addValue = APIState.useAPIState((state) => state.addValue)
const { addValue, getTemplates } = APIState.useAPIState((state) => ({
getTemplates: state.getTemplates,
addValue: state.addValue,
}))

const [template, setTemplate] = useState(defaultTemplates[0])
const [template, setTemplate] = useState(getTemplates()[0])
const [values, setValues] = useState<APIManagerValue>({
...template.defaultValues,
configName: template.name,
Expand Down Expand Up @@ -66,7 +68,7 @@ const AddAPI = () => {
<ScrollView style={{ flex: 1 }}>
<Dropdown
value={template}
data={defaultTemplates}
data={getTemplates()}
labelField="name"
valueField="name"
onChange={(item) => {
Expand Down
6 changes: 3 additions & 3 deletions app/components/APIManager/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ButtonPrimary from '@components/Buttons/ButtonPrimary'
import { APIState } from '@constants/API/APIManagerState'
import { Style } from '@constants/Style'
import { Ionicons } from '@expo/vector-icons'
import { APIState } from 'constants/API/APIManagerState'
import { Style } from 'constants/Style'
import { Stack, useRouter } from 'expo-router'
import { FlatList, StyleSheet, View, Text } from 'react-native'
import { FlatList, StyleSheet, Text, View } from 'react-native'

import APIValueItem from './APIValueItem'

Expand Down
2 changes: 1 addition & 1 deletion app/components/Alert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Style } from '@globals'
import { Style } from 'constants/Global'
import React, { ReactNode } from 'react'
import { Modal, View, Text, TouchableOpacity, StyleSheet } from 'react-native'
import Animated, { FadeInDown } from 'react-native-reanimated'
Expand Down
2 changes: 1 addition & 1 deletion app/components/AnimatedEllipsis.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Octicons } from '@expo/vector-icons'
import { Style } from '@globals'
import { Style } from 'constants/Global'
import { useEffect } from 'react'
import { View } from 'react-native'
import Animated, {
Expand Down
2 changes: 1 addition & 1 deletion app/components/Buttons/ButtonPrimary.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Style } from '@globals'
import { Style } from 'constants/Global'
import {
Text,
PressableProps,
Expand Down
4 changes: 2 additions & 2 deletions app/components/CharacterMenu/CharacterEditPopup.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Alert from '@components/Alert'
import PopupMenu, { MenuRef } from '@components/PopupMenu'
import { CharInfo } from '@constants/Characters'
import { Characters } from '@globals'
import { CharInfo } from 'constants/Characters'
import { Characters } from 'constants/Global'
import { useRouter } from 'expo-router'

type CharacterEditPopupProps = {
Expand Down
4 changes: 2 additions & 2 deletions app/components/CharacterMenu/CharacterList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CharInfo } from '@constants/Characters'
import { CharInfo } from 'constants/Characters'
import { AntDesign } from '@expo/vector-icons'
import { Characters, Style } from '@globals'
import { Characters, Style } from 'constants/Global'
import { useLiveQuery } from 'drizzle-orm/expo-sqlite'
import { Stack } from 'expo-router'
import { useEffect, useState } from 'react'
Expand Down
4 changes: 2 additions & 2 deletions app/components/CharacterMenu/CharacterListing.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Avatar from '@components/Avatar'
import { CharInfo } from '@constants/Characters'
import { Characters, Chats, Logger, Style } from '@globals'
import { CharInfo } from 'constants/Characters'
import { Characters, Chats, Logger, Style } from 'constants/Global'
import { View, Text, StyleSheet, TouchableOpacity, ActivityIndicator } from 'react-native'

import CharacterEditPopup from './CharacterEditPopup'
Expand Down
2 changes: 1 addition & 1 deletion app/components/CharacterMenu/CharacterNewMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { MenuRef } from '@components/PopupMenu'
import TextBoxModal from '@components/TextBoxModal'
import { AntDesign } from '@expo/vector-icons'
import { Characters, Chats, Logger, Style } from '@globals'
import { Characters, Chats, Logger, Style } from 'constants/Global'
import { useFocusEffect, useRouter } from 'expo-router'
import { useRef, useState } from 'react'
import { StyleSheet, TouchableOpacity, Text, BackHandler, View } from 'react-native'
Expand Down
Loading

0 comments on commit cad89d7

Please sign in to comment.