Skip to content

Commit

Permalink
Add fit page to window reader setting (#323)
Browse files Browse the repository at this point in the history
* Add fit page to window reader setting

* Renamed option and conditional rendering

* Rename translation key
  • Loading branch information
Alexandre-P-J authored Jun 3, 2023
1 parent 46a7ff6 commit d60ed0c
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/navbar/ReaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ export default function ReaderNavBar(props: IProps) {
showPageNumber={settings.showPageNumber}
loadNextOnEnding={settings.loadNextOnEnding}
skipDupChapters={settings.skipDupChapters}
fitPageToWindow={settings.fitPageToWindow}
readerType={settings.readerType}
/>
</Collapse>
Expand Down
1 change: 1 addition & 0 deletions src/components/reader/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function imageStyle(settings: IReaderSettings): any {
};
}, []);
if (
settings.fitPageToWindow ||
settings.readerType === 'DoubleLTR' ||
settings.readerType === 'DoubleRTL' ||
settings.readerType === 'ContinuesHorizontalLTR' ||
Expand Down
21 changes: 20 additions & 1 deletion src/components/reader/ReaderSettingsOptions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@ export default function ReaderSettingsOptions({
showPageNumber,
skipDupChapters,
setSettingValue,
fitPageToWindow,
}: IProps) {
const { t } = useTranslation();

const fitPageToWindowEligible = [
'ContinuesVertical',
'Webtoon',
'SingleVertical',
'SingleRTL',
'SingleLTR',
].includes(readerType);
return (
<List>
<ListItem>
Expand Down Expand Up @@ -70,6 +77,18 @@ export default function ReaderSettingsOptions({
/>
</ListItemSecondaryAction>
</ListItem>
{fitPageToWindowEligible ? (
<ListItem>
<ListItemText primary={t('reader.settings.label.fit_page_to_window')} />
<ListItemSecondaryAction>
<Switch
edge="end"
checked={fitPageToWindow}
onChange={(e) => setSettingValue('fitPageToWindow', e.target.checked)}
/>
</ListItemSecondaryAction>
</ListItem>
) : null}
<ListItem>
<ListItemText primary={t('reader.settings.label.reader_type')} />
<Select
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locale/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@
"reader_type": "Reader type",
"show_page_number": "Show page number",
"skip_dup_chapters": "Skip duplicate chapters",
"static_navigation": "Static navigation"
"static_navigation": "Static navigation",
"fit_page_to_window": "Fit page to window"
},
"reader_type": {
"label": {
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,8 @@
"static_navigation": "Navigación Estática",
"show_page_number": "Mostrar numero de pagina",
"reader_type": "Tipo de Lector",
"skip_dup_chapters": "Omitir capítulos duplicados"
"skip_dup_chapters": "Omitir capítulos duplicados",
"fit_page_to_window": "Ajustar página a la ventana"
},
"title": {
"default_reader_settings": "Ajustes Defecto del Lector",
Expand Down
1 change: 1 addition & 0 deletions src/screens/settings/DefaultReaderSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default function DefaultReaderSettings() {
showPageNumber={settings.showPageNumber}
loadNextOnEnding={settings.loadNextOnEnding}
skipDupChapters={settings.skipDupChapters}
fitPageToWindow={settings.fitPageToWindow}
readerType={settings.readerType}
/>
);
Expand Down
1 change: 1 addition & 0 deletions src/typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ export interface IReaderSettings {
showPageNumber: boolean;
loadNextOnEnding: boolean;
skipDupChapters: boolean;
fitPageToWindow: boolean;
readerType: ReaderType;
}

Expand Down
2 changes: 2 additions & 0 deletions src/util/readerSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const getDefaultSettings = (): IReaderSettings => ({
showPageNumber: true,
loadNextOnEnding: false,
skipDupChapters: true,
fitPageToWindow: false,
readerType: 'ContinuesVertical',
});

Expand Down Expand Up @@ -71,6 +72,7 @@ export const checkAndHandleMissingStoredReaderSettings = async (
showPageNumber: undefined,
loadNextOnEnding: undefined,
skipDupChapters: undefined,
fitPageToWindow: undefined,
readerType: undefined,
},
false,
Expand Down

0 comments on commit d60ed0c

Please sign in to comment.