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

feat: format files and add workflow #169

Merged
merged 4 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
45 changes: 45 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Code quality - linting and typechecking

on:
push:
branches:
- master
pull_request:
types: [opened, synchronize]

jobs:
linting:
runs-on: ubuntu-latest
steps:
- name: 🏗 Setup repo
uses: actions/checkout@v3

- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: 17
distribution: "temurin"

- name: 🏗 Setup Node
uses: actions/setup-node@v3
with:
node-version: 18.x
cache: yarn

- name: 🏗 Setup EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}

- name: 📦 Install dependencies
run: yarn install

- name: 🧹 Linting
run: yarn lint:js

- name: ✨ Prettier
run: yarn format

- name: 🔎 Typechecking
run: yarn tsc:compile
5 changes: 0 additions & 5 deletions .lintstagedrc.json

This file was deleted.

4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"typescript.preferences.importModuleSpecifier": "non-relative",
"editor.codeActionsOnSave": {
"source.removeUnusedImports": "explicit"
"source.organizeImports": "always"
}
}
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
![image](https://github.com/user-attachments/assets/c41c4ae2-ab4f-4fd8-8012-c6d3fbd8ca87)


# Alby Go

A simple lightning mobile wallet interface that works great with [Alby Hub](https://albyhub.com) or any other [NWC](https://nwc.dev) wallet service.
Expand Down
31 changes: 18 additions & 13 deletions RELEASE.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
# Release
# Release

1. Update version in
- `app.json`
- `package.json`
1. Update version in

2. Create a git tag and push it (a new draft release will be created)
- `git tag v1.2.3`
- `git push origin tag v1.2.3`
- Update the release notes and publish the release (APK will be built and added automatically)
- `app.json`
- `package.json`

2. Create a git tag and push it (a new draft release will be created)

- `git tag v1.2.3`
- `git push origin tag v1.2.3`
- Update the release notes and publish the release (APK will be built and added automatically)

3. Build packages
- `yarn eas:build:android`
- `yarn eas:build:ios`

- `yarn eas:build:android`
- `yarn eas:build:ios`

3. Submit to app stores
- `eas submit --platform android`
- `eas submit --platform ios`

- `eas submit --platform android`
- `eas submit --platform ios`

# Zapstore

Install required software:

- `sudo apt install apksigner apktool`
- https://github.com/sibprogrammer/xq
- https://github.com/zapstore/zapstore-cli

Then publish the release

1. `zapstore publish albygo -v <version>` (<version> without the `v` prefix)
1. Use nsec to sign release events

50 changes: 25 additions & 25 deletions app/(app)/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
import { Redirect, Stack } from 'expo-router';
import { useSession } from '~/hooks/useSession';
import { useHandleLinking } from '~/hooks/useHandleLinking';
import { useAppStore } from '~/lib/state/appStore';
import { useRouteInfo } from 'expo-router/build/hooks';
import { Redirect, Stack } from "expo-router";
import { useRouteInfo } from "expo-router/build/hooks";
import { useHandleLinking } from "~/hooks/useHandleLinking";
import { useSession } from "~/hooks/useSession";
import { useAppStore } from "~/lib/state/appStore";

export default function AppLayout() {
const { hasSession } = useSession();
const isOnboarded = useAppStore(store => store.isOnboarded);
const wallets = useAppStore(store => store.wallets);
const route = useRouteInfo();
useHandleLinking();
const { hasSession } = useSession();
const isOnboarded = useAppStore((store) => store.isOnboarded);
const wallets = useAppStore((store) => store.wallets);
const route = useRouteInfo();
useHandleLinking();

if (!isOnboarded) {
console.log("Not onboarded, redirecting to /onboarding")
return <Redirect href="/onboarding" />;
}
if (!isOnboarded) {
console.info("Not onboarded, redirecting to /onboarding");
return <Redirect href="/onboarding" />;
}

if (!hasSession) {
console.log("Not authenticated, redirecting to /unlock")
return <Redirect href="/unlock" />;
}
if (!hasSession) {
console.info("Not authenticated, redirecting to /unlock");
return <Redirect href="/unlock" />;
}

const connectionPage = "/settings/wallets/setup";
// Check the current pathname to prevent redirect loops
if (!wallets.length && route.pathname !== connectionPage) {
console.log("No wallets available, redirecting to setup");
return <Redirect href={connectionPage} />;
}
const connectionPage = "/settings/wallets/setup";
// Check the current pathname to prevent redirect loops
if (!wallets.length && route.pathname !== connectionPage) {
console.info("No wallets available, redirecting to setup");
return <Redirect href={connectionPage} />;
}

return <Stack />;
return <Stack />;
}
42 changes: 20 additions & 22 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import "~/global.css";
import { Theme, ThemeProvider } from "@react-navigation/native";
import {
Slot,
SplashScreen
} from "expo-router";
import { PortalHost } from "@rn-primitives/portal";
import * as Font from "expo-font";
import { Slot, SplashScreen } from "expo-router";
import { StatusBar } from "expo-status-bar";
import { swrConfiguration } from "lib/swr";
import * as React from "react";
import { SafeAreaView } from "react-native";
import { NAV_THEME } from "~/lib/constants";
import { useColorScheme } from "~/lib/useColorScheme";
import Toast from "react-native-toast-message";
import PolyfillCrypto from "react-native-webview-crypto";
import { SWRConfig } from "swr";
import { swrConfiguration } from "lib/swr";
import Toast from "react-native-toast-message";
import { toastConfig } from "~/components/ToastConfig";
import * as Font from "expo-font";
import { useInfo } from "~/hooks/useInfo";
import { useAppStore } from "~/lib/state/appStore";
import { UserInactivityProvider } from "~/context/UserInactivity";
import { PortalHost } from '@rn-primitives/portal';
import { isBiometricSupported } from "~/lib/isBiometricSupported";
import "~/global.css";
import { useInfo } from "~/hooks/useInfo";
import { SessionProvider } from "~/hooks/useSession";
import { NAV_THEME } from "~/lib/constants";
import { isBiometricSupported } from "~/lib/isBiometricSupported";
import { useAppStore } from "~/lib/state/appStore";
import { useColorScheme } from "~/lib/useColorScheme";

const LIGHT_THEME: Theme = {
dark: false,
Expand Down Expand Up @@ -61,7 +58,7 @@ export default function RootLayout() {
}

async function checkBiometricStatus() {
const isSupported = await isBiometricSupported()
const isSupported = await isBiometricSupported();
if (!isSupported) {
useAppStore.getState().setSecurityEnabled(false);
}
Expand All @@ -70,12 +67,8 @@ export default function RootLayout() {
React.useEffect(() => {
const init = async () => {
try {
await Promise.all([
loadFonts(),
checkBiometricStatus(),
]);
}
finally {
await Promise.all([loadFonts(), checkBiometricStatus()]);
} finally {
SplashScreen.hideAsync();
}
};
Expand All @@ -98,7 +91,12 @@ export default function RootLayout() {
<Slot />
</SessionProvider>
</UserInactivityProvider>
<Toast config={toastConfig} position="bottom" bottomOffset={140} topOffset={140} />
<Toast
config={toastConfig}
position="bottom"
bottomOffset={140}
topOffset={140}
/>
<PortalHost />
</SafeAreaView>
</ThemeProvider>
Expand Down
2 changes: 1 addition & 1 deletion components.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
"components": "~/components",
"lib": "~/lib"
}
}
}
100 changes: 53 additions & 47 deletions components/AlbyBanner.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,67 @@
import { router } from "expo-router";
import { View } from "react-native";
import { Text } from "~/components/ui/text";
import { Button } from "./ui/button";
import { router } from "expo-router";
import { useAppStore } from "~/lib/state/appStore";
import { ALBY_LIGHTNING_ADDRESS } from "~/lib/constants";
import { useAppStore } from "~/lib/state/appStore";
import { Button } from "./ui/button";

function AlbyBanner() {
const lastPayment = useAppStore
.getState()
.getLastAlbyPayment();
const showAlbyBanner = isPaymentOlderThan24Hours(lastPayment);
const amounts = [
{ value: 1000, label: "1k", emoji: '🧡' },
{ value: 5000, label: "5k", emoji: '🔥' },
{ value: 10000, label: "10k", emoji: '🚀' }
];
const lastPayment = useAppStore.getState().getLastAlbyPayment();
const showAlbyBanner = isPaymentOlderThan24Hours(lastPayment);
const amounts = [
{ value: 1000, label: "1k", emoji: "🧡" },
{ value: 5000, label: "5k", emoji: "🔥" },
{ value: 10000, label: "10k", emoji: "🚀" },
];

function isPaymentOlderThan24Hours(paymentDate: Date | null) {
if (!paymentDate) return true;

const currentDate = new Date();
const millisecondsIn24Hours = 24 * 60 * 60 * 1000; // 24 hours

return (currentDate.getTime() - paymentDate.getTime()) > millisecondsIn24Hours;
function isPaymentOlderThan24Hours(paymentDate: Date | null) {
if (!paymentDate) {
return true;
}

if (!showAlbyBanner) {
return null;
}
const currentDate = new Date();
const millisecondsIn24Hours = 24 * 60 * 60 * 1000; // 24 hours

return (
<View className="border bg-card border-muted rounded mt-5 flex flex-col gap-3 p-5">
<Text className="font-semibold2 text-center">✨ Enjoying Alby Go?</Text>
<Text className="text-muted-foreground text-center">Help us grow and improve by supporting our development.</Text>
<View className="flex flex-row gap-3 mt-3">
{amounts.map(({ value, label, emoji }) => (
<Button
key={value}
variant="secondary"
size="sm"
className="flex-1"
onPress={() => {
router.navigate({
pathname: "/send",
params: {
url: ALBY_LIGHTNING_ADDRESS,
amount: value
},
});
}}
>
<Text>{emoji} {label}</Text>
</Button>
))}
</View>
</View>
currentDate.getTime() - paymentDate.getTime() > millisecondsIn24Hours
);
}

if (!showAlbyBanner) {
return null;
}

return (
<View className="border bg-card border-muted rounded mt-5 flex flex-col gap-3 p-5">
<Text className="font-semibold2 text-center">✨ Enjoying Alby Go?</Text>
<Text className="text-muted-foreground text-center">
Help us grow and improve by supporting our development.
</Text>
<View className="flex flex-row gap-3 mt-3">
{amounts.map(({ value, label, emoji }) => (
<Button
key={value}
variant="secondary"
size="sm"
className="flex-1"
onPress={() => {
router.navigate({
pathname: "/send",
params: {
url: ALBY_LIGHTNING_ADDRESS,
amount: value,
},
});
}}
>
<Text>
{emoji} {label}
</Text>
</Button>
))}
</View>
</View>
);
}

export default AlbyBanner;
13 changes: 9 additions & 4 deletions components/DismissableKeyboardView.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import { Platform, KeyboardAvoidingView, Keyboard, TouchableWithoutFeedback } from "react-native";
import {
Keyboard,
KeyboardAvoidingView,
Platform,
TouchableWithoutFeedback,
} from "react-native";

function DismissableKeyboardView({ children }: { children?: React.ReactNode }) {
return (
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
keyboardVerticalOffset={Platform.OS === 'ios' ? 100 : 0}
behavior={Platform.OS === "ios" ? "padding" : "height"}
keyboardVerticalOffset={Platform.OS === "ios" ? 100 : 0}
className="flex-1"
>
<TouchableWithoutFeedback onPress={Keyboard.dismiss}>
Expand All @@ -14,4 +19,4 @@ function DismissableKeyboardView({ children }: { children?: React.ReactNode }) {
);
}

export default DismissableKeyboardView;
export default DismissableKeyboardView;
Loading
Loading