Skip to content

Commit

Permalink
Add passkeys login to iOS app
Browse files Browse the repository at this point in the history
  • Loading branch information
TimDaub committed Feb 3, 2025
1 parent f4cec2b commit e72ba3e
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
8 changes: 0 additions & 8 deletions src/public/news.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,6 @@
--table-bg-mobile: rgb(255, 255, 250);
--visited-link: #828282;
}
html.kiwi-ios-app .bottom-nav,
html.kiwi-ios-app .vote-button-container,
html.kiwi-ios-app .site-explainer {
display: none !important;
}
html.kiwi-ios-app .content-container {
margin-left: 11px;
}
.scroll-margin-base, .scroll-margin-with-image {
scroll-margin-top: 100px;
}
Expand Down
54 changes: 53 additions & 1 deletion src/web/src/Bell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,61 @@ import { useEffect, useState } from "react";
import { WagmiConfig, useAccount } from "wagmi";
import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { eligible } from "@attestate/delegator2";
import SwipeableDrawer from "@mui/material/SwipeableDrawer";

import { Connector, TextConnectButton } from "./Navigation.jsx";
import { RestoreDialogue } from "./Passkeys.jsx";
import { fetchNotifications } from "./API.mjs";
import { getLocalAccount, getCookie } from "./session.mjs";
import { isIOS, getLocalAccount, getCookie } from "./session.mjs";
import { client, chains } from "./client.mjs";
import { dynamicPrefetch } from "./main.jsx";

const IOSAppLogin = ({ allowlist, delegations, toast }) => {
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
const PasskeysLogin = RestoreDialogue(allowlist, delegations, toast);

return (
<>
<button
onClick={() => setIsDrawerOpen(true)}
style={{
padding: "8px 0",
border: "none",
borderRadius: "2px",
backgroundColor: "#E2F266",
color: "black",
fontSize: "8pt",
cursor: "pointer",
width: "100%",
}}
>
Login
</button>

<SwipeableDrawer
anchor="bottom"
open={isDrawerOpen}
onClose={() => setIsDrawerOpen(false)}
onOpen={() => setIsDrawerOpen(true)}
disableBackdropTransition={!isIOS()}
disableDiscovery={isIOS()}
>
<div
style={{
height: "100%",
display: "flex",
alignItems: "center",
justifyContent: "center",
padding: "3rem 0",
}}
>
<PasskeysLogin />
</div>
</SwipeableDrawer>
</>
);
};

let wasTitleSet = false;
const Bell = (props) => {
let address;
Expand Down Expand Up @@ -81,8 +129,12 @@ const Bell = (props) => {
) {
return null;
}
const isIOSApp = document.documentElement.classList.contains("kiwi-ios-app");

if (!getCookie("identity") || !isEligible) {
if (isIOSApp) {
return <IOSAppLogin {...props} />;
}
return (
<TextConnectButton
className={props.mobile ? "mobile-bell" : "bell-button"}
Expand Down
1 change: 0 additions & 1 deletion src/web/src/Passkeys.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export const RestoreDialogue = (allowlist, delegations, toast) => {
alignItems: "center",
fontSize: "15px",
gap: "4px",
border: "1px solid #828282",
borderRadius: "2px",
padding: "0.4rem 0.75rem",
display: "flex",
Expand Down

0 comments on commit e72ba3e

Please sign in to comment.