Skip to content

Commit

Permalink
tsukota: Add name to Config and use it
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jun 29, 2023
1 parent 3435f81 commit 7f3363a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/tsukota/App.tsx
Expand Up @@ -51,6 +51,7 @@ import {
Screen,
} from "./components";
import { CredentialProvider, useCurrentUserId } from "./hooks/use-credential";
import { getConfig } from "./lib/config";
import { useTranslation } from "./lib/i18n";
import { SafeAreaView } from "react-native-safe-area-context";
import Toast from "react-native-root-toast";
Expand Down Expand Up @@ -194,11 +195,8 @@ function User(): JSX.Element {
}

function AppInfo(): JSX.Element {
// TODO: get value
const appName = "tsukota";
const appVersion = "0.2.0";
const appPackageName = "net.bouzuya.lab.tsukota";
const playStoreUrl = `https://play.google.com/store/apps/details?id=${appPackageName}`;
const { name, packageName, version } = getConfig();
const playStoreUrl = `https://play.google.com/store/apps/details?id=${packageName}`;
return (
<TouchableOpacity
onPress={() => void Linking.openURL(playStoreUrl)}
Expand Down Expand Up @@ -232,8 +230,8 @@ function AppInfo(): JSX.Element {
paddingHorizontal: 0,
}}
>
<Text>{appName}</Text>
<Text>v{appVersion}</Text>
<Text>{name}</Text>
<Text>v{version}</Text>
</View>
</View>
</TouchableOpacity>
Expand Down Expand Up @@ -263,8 +261,7 @@ type DrawerLayoutProps = {
function DrawerLayout({ backgroundColor }: DrawerLayoutProps): JSX.Element {
const navigation = useNavigation<DrawerNavigationProp<DrawerParamList>>();
const { t } = useTranslation();
// TODO: get value
const appName = "tsukota";
const { name } = getConfig();
// TODO: set onPress event handler
// TODO: i18n
return (
Expand All @@ -277,7 +274,7 @@ function DrawerLayout({ backgroundColor }: DrawerLayoutProps): JSX.Element {
]}
>
<RNPDrawer.Section>
<RNPDrawer.Item label={appName} />
<RNPDrawer.Item label={name} />
</RNPDrawer.Section>
<RNPDrawer.Section>
<RNPDrawer.Item
Expand Down
4 changes: 4 additions & 0 deletions packages/tsukota/lib/config.ts
Expand Up @@ -6,6 +6,7 @@ type Config = {
enableDebugLogging: boolean;
firestoreEmulatorHost: string;
functionsEmulatorHost: string;
name: string;
packageName: string;
projectId: string;
version: string;
Expand All @@ -25,6 +26,8 @@ export function getConfig(): Config {
if (packageName === undefined)
throw new Error("assert android.package !== undefined");

const name = expoConfig.name;

const version = expoConfig.version;
if (version === undefined) throw new Error("assert version !== undefined");

Expand Down Expand Up @@ -72,6 +75,7 @@ export function getConfig(): Config {
enableDebugLogging: enableDebugLogging === "true",
firestoreEmulatorHost,
functionsEmulatorHost,
name,
packageName,
projectId,
version,
Expand Down

0 comments on commit 7f3363a

Please sign in to comment.