Skip to content
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

Android app setup SNS-35 #26

Merged
merged 50 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
2312e05
chore: Minimal runable solution
letehaha Aug 9, 2023
bacac18
docs: Add simple readme to simplify env setup
letehaha Aug 9, 2023
8a9b8bd
feat: Improve .gitignore
letehaha Aug 9, 2023
8724398
chore: revert incorrect changes
letehaha Aug 9, 2023
cce5c14
feat: Add fully workable solution
letehaha Aug 28, 2023
522c21d
chore: Fix small issues
letehaha Aug 28, 2023
0a248a5
fix: UI issues accross the app
letehaha Aug 29, 2023
7a053f5
fix: UI issues
letehaha Aug 30, 2023
9f4245d
feat: Implement wallet connection
letehaha Aug 30, 2023
3db7c68
fix: Runtime error
letehaha Aug 30, 2023
4796426
feat: Add script to build mobile apk
letehaha Aug 30, 2023
b01a245
fix: StatusBar displaying
letehaha Aug 30, 2023
58536b2
fix: Styles issues
letehaha Aug 30, 2023
b8dce28
fix: Sticky functionality on domain page
letehaha Aug 30, 2023
6230340
chore: Small fixes
letehaha Aug 30, 2023
742adde
fix: App crash if no wallets installed on the device
letehaha Aug 31, 2023
7c39a1e
fix: Broken domain tabs scroll on web
letehaha Sep 1, 2023
36bab2f
fix: App crashing when calling `wallet.authorize` on android
letehaha Sep 1, 2023
07b3feb
fix: SVG icons in the cart
letehaha Sep 1, 2023
3f90ba3
fix: Success page after purchasing
letehaha Sep 1, 2023
8725984
feat: change RPC url and move it to .env
letehaha Sep 5, 2023
f30cdc2
chore: Optimize default-pic image size
letehaha Sep 5, 2023
2d9bdf3
feat: Define correct icons for Android app
letehaha Sep 5, 2023
7f6ae88
chore: Improve Android app package name
letehaha Sep 6, 2023
076e74c
fix: APP_IDENTITY on mobile device
letehaha Sep 6, 2023
382d5e2
chore: Add solana dapp init config
letehaha Sep 6, 2023
233a0d8
feat: Add preparations for the first release
letehaha Sep 7, 2023
23e4e45
chore: Update .nvmrc
letehaha Sep 26, 2023
7cb6eb4
chore: Update solana dapp config
letehaha Sep 26, 2023
ba9667d
add addresses to config file
dr497 Sep 27, 2023
3eebe13
add address release
dr497 Sep 27, 2023
623ba02
Create .gitignore
dr497 Sep 27, 2023
484ade4
fix: application whitescreen
letehaha Sep 29, 2023
a683b24
new mobile app release
dr497 Oct 2, 2023
e2436d2
fix: app performance
letehaha Oct 3, 2023
0b890b2
chore: patch "versionCode"
letehaha Oct 4, 2023
7d726d5
new mobile release
dr497 Oct 4, 2023
d9e02e6
new mobile release
dr497 Oct 10, 2023
4b5057a
chore: code cleanup
letehaha Oct 12, 2023
2a69c60
chore: Add play-store screenshots to assets
letehaha Oct 25, 2023
d6b2581
Merge branch 'master' into feat/android-app
letehaha Oct 25, 2023
83fb647
chore: Update .gitignore
letehaha Nov 8, 2023
7621240
chore: Switch from yarn to npm
letehaha Nov 9, 2023
3ee12e2
feat: Add CI to verify all entries can be built
letehaha Nov 9, 2023
f26b3f8
fix: dependencies list to fix mobile build
letehaha Nov 9, 2023
b408a82
fix: Broken mobile build
letehaha Nov 9, 2023
6c555f5
feat: Add Privacy Policy link to Android app
letehaha Nov 10, 2023
7f29a52
fix: Update Expo app config
letehaha Nov 10, 2023
85b1180
chore: Update translations
letehaha Nov 10, 2023
1a4aebe
feat: Add Android build to CI
letehaha Nov 10, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ xnft-bundle.zip

# macOS
.DS_Store
.env
.env

# Android
*.apk
9 changes: 8 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
"expo": {
"name": "SNS Manager",
"slug": "sns-manager",
"entryPoint": "./src/App"
"extra": {
"eas": {
"projectId": "6a58dd40-2599-4f45-befe-c1ebe9766c1e"
}
},
"android": {
"package": "bonfida.sns_manager"
}
}
}
1 change: 1 addition & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = function (api) {
presets: ["babel-preset-expo"],
plugins: [
"transform-inline-environment-variables",
"react-native-reanimated/plugin",
"macros",
[
"module-resolver",
Expand Down
15 changes: 15 additions & 0 deletions eas.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"build": {
"development": {
"developmentClient": true,
"distribution": "internal"
},
"preview": {
"distribution": "internal",
"android": {
"buildType": "apk"
}
},
"production": {}
letehaha marked this conversation as resolved.
Show resolved Hide resolved
}
}
4 changes: 4 additions & 0 deletions metro.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Learn more https://docs.expo.io/guides/customizing-metro
const { getDefaultConfig } = require('expo/metro-config');

module.exports = getDefaultConfig(__dirname);
20 changes: 17 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
"scripts": {
"build:xnft": "XNFT=true expo export:web",
"build:web": "WEB=true expo export:web && cp _headers web-build/",
"build:mobile-apk": "eas build -p android --profile preview --local",
"start": "yarn build:xnt && npx xnft web",
"bundle": "yarn build:xnft && npx xnft bundle",
"dev": "GENERATE_SOURCEMAP=false expo start --clear --web & npx xnft --iframe http://localhost:19006",
"dev:xnft": "XNFT=true yarn dev",
"dev:web": "WEB=true yarn dev",
"dev:mobile": "expo start --dev-client --clear",
"dev:mobile:build": "eas build --profile development --platform android --local",
"extract": "lingui extract",
"compile": "lingui compile",
"format": "npx prettier --write src/**/*.{ts,tsx}",
"prepare": "husky install"
},
"main": "./src/App",
"dependencies": {
"@adraffy/ens-normalize": "^1.9.0",
"@bonfida/name-offers": "^0.0.10",
Expand All @@ -29,32 +33,39 @@
"@lingui/macro": "^4.2.0",
"@lingui/react": "^4.2.0",
"@pythnetwork/client": "^2.17.0",
"@react-native-async-storage/async-storage": "1.17.11",
"@react-native-clipboard/clipboard": "^1.11.2",
"@react-navigation/bottom-tabs": "6.3.1",
"@react-navigation/native": "6.0.10",
"@react-navigation/native-stack": "6.6.1",
"@react-navigation/stack": "6.2.1",
"@solana-mobile/mobile-wallet-adapter-protocol": "^2.0.1",
"@solana-mobile/mobile-wallet-adapter-protocol-web3js": "^2.0.1",
"@solana/buffer-layout": "^4.0.1",
"@solana/spl-token": "^0.3.7",
"@solana/wallet-adapter-react": "^0.15.32",
"@solana/wallet-adapter-react-ui": "^0.9.31",
"@solana/web3.js": "^1.75.0",
"axios": "^1.4.0",
"buffer": "^6.0.3",
"expo": "~48.0.7",
"expo": "~48.0.18",
"expo-blur": "~12.2.2",
"expo-constants": "~14.2.1",
"expo-dev-client": "~2.2.1",
"expo-image-picker": "~14.1.1",
"expo-linear-gradient": "~12.1.2",
"expo-splash-screen": "~0.18.2",
"expo-status-bar": "~1.4.4",
"react": "18.2.0",
"react-async-hook": "^4.0.0",
"react-dom": "18.2.0",
"react-error-overlay": "6.0.11",
"react-native": "0.71.8",
"react-native-gesture-handler": "~2.9.0",
"react-native-get-random-values": "~1.9.0",
"react-native-heroicons": "^3.2.0",
"react-native-modalfy": "^3.4.0",
"react-native-reanimated": "~2.14.4",
"react-native-safe-area-context": "4.5.0",
"react-native-screens": "~3.20.0",
"react-native-skeleton-content": "^1.0.28",
Expand Down Expand Up @@ -82,6 +93,9 @@
"xnft": "latest"
},
"resolutions": {
"react-error-overlay": "6.0.11"
}
"react-error-overlay": "6.0.11",
"react-native-reanimated": "2.14.4"
},
"name": "sns-manager",
"version": "0.0.1"
}
56 changes: 16 additions & 40 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
// Required to fix the issue with "crypto.getRandomValues() not supported"
// https://github.com/uuidjs/uuid#getrandomvalues-not-supported
// https://github.com/uuidjs/uuid/issues/416
// TODO: load only for Android separately using .android.tsx suffix
import "react-native-get-random-values";

window.Buffer = window.Buffer || require("buffer").Buffer;
global.Buffer = global.Buffer || require("buffer").Buffer;

import { registerRootComponent } from "expo";
import { RecoilRoot, useRecoilState } from "recoil";
import { ActivityIndicator, View } from "react-native";
import { ActivityIndicator, View, Text } from "react-native";
import { ReactNode, useEffect } from "react";
import { NavigationContainer } from "@react-navigation/native";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { useFonts, AzeretMono_400Regular } from "@expo-google-fonts/dev";
import { HomeScreen } from "./screens/HomeScreen";
import { ProfileScreen } from "./screens/Profile";
import { Feather } from "@expo/vector-icons";
import { cartState } from "./atoms/cart";
import { Text } from "react-native";
import tw from "./utils/tailwind";
import { Cart } from "./screens/Cart";
import { ModalProvider, createModalStack } from "react-native-modalfy";
Expand All @@ -21,15 +27,8 @@ import { EditPicture } from "./components/EditPicture";
import { ProgressExplainerModal } from "./components/ProgressExplainerModal";
import { SearchModal } from "./components/SearchModal";
import { DiscountExplainerModal } from "./components/DiscountExplainerModal";
import { isXnft, isMobile, isWeb } from "./utils/platform";
import { ReactNode, useEffect, useMemo } from "react";
import {
ConnectionProvider,
WalletProvider,
} from "@solana/wallet-adapter-react";
import { WalletModalProvider } from "@solana/wallet-adapter-react-ui";
import { isXnft, isMobile, isWeb } from "@src/utils/platform";
import { useWallet } from "./hooks/useWallet";
import { URL } from "./utils/rpc";
import { useReferrer } from "./hooks/useReferrer";
import { DomainSizeModal } from "./components/DomainSizeModal";
import { DeleteModal } from "./components/DeleteModal";
Expand All @@ -46,6 +45,7 @@ import { LanguageModal } from "./components/LanguageModal";
import { TokenizeModal } from "./components/TokenizeModal";
import { NavigatorTabsParamList } from "@src/types";
import { LanguageHeader } from "@src/components/Header";
import { SolanaProvider } from "@src/providers/SolanaProvider";

const xnftjson = require("../xnft.json");

Expand Down Expand Up @@ -82,11 +82,13 @@ function TabNavigator() {
useReferrer();
const [cart] = useRecoilState(cartState);
const { publicKey, setVisible, connected } = useWallet();

const { currentLanguage } = useLanguageContext();

useEffect(() => {
console.table(isMobile, isXnft, isWeb);
if (isXnft) return;
// Do not authorize automatically
if (isXnft || isMobile) return;
if (!connected) {
setVisible(true);
}
Expand Down Expand Up @@ -181,7 +183,7 @@ function App() {
}

return (
<Wrap>
<SolanaProvider>
<RecoilRoot>
<NavigationContainer>
<LanguageProvider i18n={i18n}>
Expand All @@ -193,34 +195,8 @@ function App() {
</LanguageProvider>
</NavigationContainer>
</RecoilRoot>
</Wrap>
</SolanaProvider>
);
}

const Wrap = ({ children }: { children: ReactNode }) => {
const wallets = useMemo(() => [], []);
if (isXnft) {
return <>{children}</>;
}
if (isWeb) {
return (
<ConnectionProvider endpoint={URL}>
<WalletProvider autoConnect wallets={wallets}>
<WalletModalProvider>{children}</WalletModalProvider>
</WalletProvider>
</ConnectionProvider>
);
}
if (isMobile) {
return (
<ConnectionProvider endpoint={URL}>
<WalletProvider autoConnect wallets={wallets}>
<WalletModalProvider>{children}</WalletModalProvider>
</WalletProvider>
</ConnectionProvider>
);
}
return <>{children}</>;
};

export default registerRootComponent(App);
registerRootComponent(App);
2 changes: 1 addition & 1 deletion src/components/DomainSearchResultRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const DomainSearchResultRow = ({
: () => navigation.navigate("domain-view", { domain })
}
style={[
tw`p-2 h-[32px] w-[32px] flex items-center justify-center`,
tw`h-[32px] w-[32px] flex items-center justify-center`,
available && tw`border rounded-md border-brand-primary`,
available && !inCart && tw`bg-brand-primary`,
]}
Expand Down
13 changes: 7 additions & 6 deletions src/components/DomainSizeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ export const DomainSizeModal = ({
store on your domain.
</Trans>
</Text>
<Text style={tw`mt-2 text-xs`}>
<View style={tw`flex flex-row gap-1 mt-2`}>
<MaterialCommunityIcons
name="information-outline"
size={16}
style={tw`mr-1`}
color={tw.color("content-warning")}
/>
<Trans>
Each additional kb of memory costs around 0.007 SOL (0.001 USDC)
</Trans>
</Text>
<Text style={tw`text-xs`}>
<Trans>
Each additional kb of memory costs around 0.007 SOL (0.001 USDC)
</Trans>
</Text>
</View>

<View style={tw`flex flex-row flex-wrap items-center gap-3 mt-3`}>
{LIST.map((e) => {
Expand Down
1 change: 0 additions & 1 deletion src/components/EditPicture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ export const EditPicture = ({
<UiButton
disabled={loading}
onPress={connected ? handlePickImage : () => setVisible(true)}
style={tw`flex flex-row items-center justify-center`}
content={t`Upload a picture...`}
loading={loading}
/>
Expand Down
13 changes: 7 additions & 6 deletions src/components/OrderSummary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const OrderSummary = ({

<Row
value={
<Text style={tw`flex flex-col items-end`}>
<View style={tw`flex flex-col items-end`}>
<Text>
{isFida && (
<>
Expand All @@ -50,7 +50,7 @@ export const OrderSummary = ({
<Text style={tw`text-xs font-medium text-content-tertiary`}>
{format(totalUsd)}
</Text>
</Text>
</View>
}
label={t`Total`}
/>
Expand All @@ -59,10 +59,11 @@ export const OrderSummary = ({
<Row
value={isFida ? "5%" : "0%"}
label={
<>
<Trans>Discount</Trans>
<View style={tw`flex flex-row items-center gap-1`}>
<Text>
<Trans>Discount</Trans>
</Text>
<TouchableOpacity
style={tw`ml-1`}
onPress={() => openModal("DiscountExplainerModal")}
>
<MaterialCommunityIcons
Expand All @@ -71,7 +72,7 @@ export const OrderSummary = ({
color={tw.color("brand-primary")}
/>
</TouchableOpacity>
</>
</View>
}
/>
</View>
Expand Down
12 changes: 8 additions & 4 deletions src/components/ProfileBlock.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Text, View, TouchableOpacity, Image } from "react-native";
import { ReactNode } from "react";
import { ReactNode, useState } from "react";
import Clipboard from "@react-native-clipboard/clipboard";
import { t } from "@lingui/macro";
import { LinearGradient } from "expo-linear-gradient";
Expand Down Expand Up @@ -30,6 +30,7 @@ export const ProfileBlock = ({
const isOwner = owner === publicKey?.toBase58();
const favorite = useFavoriteDomain(owner);
const { openModal } = useModal();
const [containerWidth, setContainerWidth] = useState(0);

return (
<LinearGradient
Expand All @@ -38,18 +39,21 @@ export const ProfileBlock = ({
tw.color("brand-accent") as string,
]}
style={tw`mt-15 p-3 pt-[50px] rounded-[20px] relative`}
onLayout={(event) => {
setContainerWidth(event.nativeEvent.layout.width);
}}
>
<View
style={[
tw`w-[100px] h-[100px] absolute top-[-60px]`,
// for some reason tailwild properties doesn't work with calc
{ left: "calc(50% - 50px)" },
// We cannot use calc(50% - 50px) because of react-native limitations
{ left: containerWidth / 2 - 50 },
]}
>
<Image
source={
picRecord.result
? picRecord.result
? { uri: picRecord.result }
: require("@assets/default-pic.png")
}
style={tw`w-full h-full rounded-full`}
Expand Down
Loading