Skip to content

Commit

Permalink
Fix height in standalone mode and disable non applike gestures
Browse files Browse the repository at this point in the history
  • Loading branch information
patdx committed Jan 5, 2025
1 parent 544a6d0 commit a93b7b5
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 67 deletions.
19 changes: 7 additions & 12 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
- syncing between devices
- use evolu or one(?) that crsqlite related thing
- disable unnecessary text highlighting
- eg when clicking the next button
- and double click triggering highlight instead of another click?
- refer to ionic css: https://github.com/ionic-team/ionic-framework/blob/1b11b82eaaa0982f98547f2854563517174c865c/core/src/css/structure.scss#L75
- better ui for navigating time
- like +10s -10s
- or a dial
- or tapping text in the transcript view
- fix speed selector
- fix background for black player page
- track time for each episode separately
- remember last time for each episode
- next episode button
- markup support
- have it fade out after a few seconds
- only show full screen button on platforms that support it (not iOS)
- add padding
- add more options to change the font size
- auto shrink large text if it does not fit
- Fix untappable buttons in PwA mode
- fix theme color/background color
- show title of program inside details page
- syncing between devices
- use evolu or one(?) that crsqlite related thing
- better ui for navigating time
- like +10s -10s
- or a dial
- or tapping text in the transcript view
32 changes: 26 additions & 6 deletions app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,32 @@
@tailwind components;
@tailwind utilities;

body {
user-select: none;
/*
Allow pan but disable zoom to avoid messing up the UI chrome
I found that I need to set it on all elements (*) to be effective in iOS Safari mode
I guess I could manually override certain elements that need other gestures later
*/
html,
body,
#app,
* {
touch-action: pan-x pan-y;
}

/* Should we use any of the properties set here? https://github.com/ionic-team/ionic-framework/blob/1b11b82eaaa0982f98547f2854563517174c865c/core/src/css/structure.scss#L75 */
/* transform: translateZ(0);
html {
overscroll-behavior: none;
}

/* https://github.com/ionic-team/ionic-framework/blob/1b11b82eaaa0982f98547f2854563517174c865c/core/src/css/structure.scss#L75 */
/* https://www.heltweg.org/posts/checklist-issues-progressive-web-apps-how-to-fix/ */

body {
user-select: none;
text-rendering: optimizeLegibility;

overflow: hidden;

touch-action: manipulation;
/* touch-action: manipulation; */

-webkit-user-drag: none;

Expand All @@ -23,5 +38,10 @@ body {
overscroll-behavior-y: none;
-webkit-text-size-adjust: none;

text-size-adjust: none; */
text-size-adjust: none;

/* Should we use any of the properties set here? https://github.com/ionic-team/ionic-framework/blob/1b11b82eaaa0982f98547f2854563517174c865c/core/src/css/structure.scss#L75 */
/* transform: translateZ(0);
*/
}
58 changes: 46 additions & 12 deletions app/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,38 @@ import {
Outlet,
Scripts,
ScrollRestoration,
useRouteLoaderData,
} from 'react-router'
import type { Route } from './+types/root'
import stylesheet from './app.css?url'

export const links: Route.LinksFunction = () => [
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{
rel: 'preconnect',
href: 'https://fonts.gstatic.com',
crossOrigin: 'anonymous',
},
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap',
},
// { rel: 'preconnect', href: 'https://fonts.googleapis.com' },
// {
// rel: 'preconnect',
// href: 'https://fonts.gstatic.com',
// crossOrigin: 'anonymous',
// },
// {
// rel: 'stylesheet',
// href: 'https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap',
// },
{ rel: 'stylesheet', href: stylesheet },
]

// Create a client
const queryClient = new QueryClient()

export function clientLoader() {
const isIos = window.navigator.userAgent.match(/iPhone|iPad|iPod/i)
return {
isIos,
}
}

export function Layout({ children }: { children: React.ReactNode }) {
const { isIos } = useRouteLoaderData<typeof clientLoader>('root') ?? {}

return (
<html lang="en">
<head>
Expand All @@ -42,6 +52,7 @@ export function Layout({ children }: { children: React.ReactNode }) {
href="/webmanifest.json"
crossOrigin="use-credentials"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta
name="apple-mobile-web-app-status-bar-style"
content="black-translucent"
Expand Down Expand Up @@ -74,8 +85,8 @@ export function Layout({ children }: { children: React.ReactNode }) {
<konsta.App
id="app"
safeAreas
theme="ios"
className="min-h-svh max-h-svh h-svh"
theme={isIos ? 'ios' : 'material'}
component={AppDiv as any}
>
{children}
</konsta.App>
Expand All @@ -87,6 +98,29 @@ export function Layout({ children }: { children: React.ReactNode }) {
)
}

// const isIosStandalone = globalThis.navigator

// https://thomashunter.name/posts/2021-12-11-detecting-if-pwa-twa-is-installed

/**
* This is a special wrapper for the Konsta App component internal div
* so I can override some of the default app classes using my own `cn()`
* classname function that includes tailwind-merge support
*/
function AppDiv(props: { className?: string; children: React.ReactNode }) {
const { className, ...rest } = props
return (
<div
className={cn(
className,
'min-h-svh max-h-svh h-svh',
'pwa:min-h-lvh pwa:max-h-lvh pwa:h-lvh',
)}
{...rest}
/>
)
}

export default function App() {
return <Outlet />
}
Expand Down
21 changes: 6 additions & 15 deletions app/routes/_index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import {
Navbar,
Page,
Block,
BlockTitle,
List,
ListItem,
Button,
} from 'konsta/react'
import type { Route } from './+types/_index'
import { useQuery } from '@tanstack/react-query'
import sampleSrtUrl from '../assets/sample.srt?url'
import { Link as RouterLink } from 'react-router'
import { Block, Button, List, ListItem, Navbar, Page } from 'konsta/react'
import { once } from 'lodash-es'
import { use } from 'react'
import { Link as RouterLink } from 'react-router'
import sampleSrtUrl from '../assets/sample.srt?url'
import type { Route } from './+types/_index'

const parseVideoPromise = once(() =>
import('video-name-parser').then((mod) => mod.default),
Expand All @@ -28,7 +20,7 @@ export function meta({}: Route.MetaArgs) {
export default function Home({ loaderData }: Route.ComponentProps) {
return (
<Page>
<Navbar title="Subtitle App" />
<Navbar title="Subtitle App" large transparent centerTitle />
<EditFilesPage />
</Page>
)
Expand Down Expand Up @@ -91,7 +83,6 @@ const EditFilesPage = () => {

return (
<>
<BlockTitle className="text-2xl px-4">Subtitle Files</BlockTitle>
<Block className="px-4">
<p className="text-sm text-gray-600">
Import and manage your subtitle files
Expand Down Expand Up @@ -160,7 +151,7 @@ const EditFilesPage = () => {
<ListItem
key={file.id}
link
linkComponent={RouterLink}
linkComponent={RouterLink as any}
linkProps={{ to: `/play?id=${file.id}` }}
title={file.name}
after={
Expand Down
12 changes: 1 addition & 11 deletions app/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,17 +102,7 @@ class ControlState {
this.showTranscript = !this.showTranscript
}
}
export const controlState = mobx.makeAutoObservable({
isOpen: true,
showTranscript: false,
showFullScreenButton: false,
toggle() {
this.isOpen = !this.isOpen
},
toggleTranscript() {
this.showTranscript = !this.showTranscript
},
})
export const controlState = new ControlState()

const getNoSleep = once(async () => {
const { default: NoSleep } = await import('nosleep.js')
Expand Down
1 change: 1 addition & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare global {
const For: typeof import('./app/shared/solid-helpers')['For']
const FullScreenIcon: typeof import('./app/shared/icons')['FullScreenIcon']
const GoBackIcon: typeof import('./app/shared/icons')['GoBackIcon']
const KonstaApp: typeof import('./app/shared/konsta-app')['KonstaApp']
const LeftIcon: typeof import('./app/shared/icons')['LeftIcon']
const LoadingIcon: typeof import('./app/shared/icons')['LoadingIcon']
const MenuIcon: typeof import('./app/shared/icons')['MenuIcon']
Expand Down
13 changes: 2 additions & 11 deletions tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,8 @@ const config = {
content: ['./app/**/{**,.client,.server}/**/*.{js,jsx,ts,tsx}'],
theme: {
extend: {
fontFamily: {
sans: [
'"Inter"',
'ui-sans-serif',
'system-ui',
'sans-serif',
'"Apple Color Emoji"',
'"Segoe UI Emoji"',
'"Segoe UI Symbol"',
'"Noto Color Emoji"',
],
screens: {
pwa: { raw: '(display-mode: standalone)' },
},
},
},
Expand Down

0 comments on commit a93b7b5

Please sign in to comment.