Add Capacitor Android packaging (APK) for Cafe Bazaar / Myket
- Next static export (output: export) wrapped by Capacitor; appId com.bargevasat.app, appName «برگ وسط» - android/ native project + @capacitor/app; hardware back handled by CapacitorBack (back a screen, exit at home) - npm scripts (cap:sync, android:open, android:apk), ANDROID.md - Gradle Maven-mirror init-script template (dl.google.com/Maven Central are blocked in Iran — same reason NuGet is mirrored) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import { ShopScreen } from "@/components/screens/ShopScreen";
|
||||
import { ChatScreen } from "@/components/screens/ChatScreen";
|
||||
import { AuthScreen } from "@/components/screens/AuthScreen";
|
||||
import { DailyRewardModal } from "@/components/online/DailyRewardModal";
|
||||
import { CapacitorBack } from "@/components/CapacitorBack";
|
||||
import { useSessionStore } from "@/lib/session-store";
|
||||
import { useGameStore } from "@/lib/game-store";
|
||||
import { useOnlineStore } from "@/lib/online-store";
|
||||
@@ -55,6 +56,7 @@ export default function Page() {
|
||||
<>
|
||||
{renderScreen(screen)}
|
||||
<DailyRewardModal />
|
||||
<CapacitorBack />
|
||||
{loading && null}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { Capacitor } from "@capacitor/core";
|
||||
import { App } from "@capacitor/app";
|
||||
import { useUIStore } from "@/lib/ui-store";
|
||||
|
||||
/**
|
||||
* Maps the Android hardware back button to in-app navigation:
|
||||
* go back a screen, or exit the app when already at home.
|
||||
* No-op on web (Capacitor.isNativePlatform() is false).
|
||||
*/
|
||||
export function CapacitorBack() {
|
||||
useEffect(() => {
|
||||
if (!Capacitor.isNativePlatform()) return;
|
||||
let remove: (() => void) | undefined;
|
||||
App.addListener("backButton", () => {
|
||||
if (useUIStore.getState().screen === "home") {
|
||||
App.exitApp();
|
||||
} else {
|
||||
window.history.back();
|
||||
}
|
||||
}).then((h) => {
|
||||
remove = () => h.remove();
|
||||
});
|
||||
return () => remove?.();
|
||||
}, []);
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user