Skip to content

Commit

Permalink
Merge pull request #1 from CD-Z/feature/export_to_epub_version_bump
Browse files Browse the repository at this point in the history
Feature/export to epub version bump
  • Loading branch information
Palloxin authored Jul 27, 2024
2 parents 7cf8692 + 8c2f8e6 commit e6e6072
Show file tree
Hide file tree
Showing 16 changed files with 637 additions and 213 deletions.
443 changes: 443 additions & 0 deletions android/app/src/main/assets/css/index.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions android/app/src/main/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class Reader {
);
document.documentElement.style.setProperty(
'--readerSettings-textSize',
settings.textSize + 'px',
settings.textSize + 'rem',
);
document.documentElement.style.setProperty(
'--readerSettings-textColor',
Expand All @@ -108,7 +108,7 @@ class Reader {
);
document.documentElement.style.setProperty(
'--readerSettings-lineHeight',
settings.lineHeight,
settings.lineHeight+"rem",
);
document.documentElement.style.setProperty(
'--readerSettings-fontFamily',
Expand Down
102 changes: 21 additions & 81 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
"start": "react-native start",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"prettier": "prettier --write \"./src/**/*.{js,jsx,ts,tsx}\" ./scripts",
"buildRelease": "node scripts/setEnvFile.cjs Release && cd android && ./gradlew clean && ./gradlew assembleRelease",
"buildRelease": "node scripts/convertCssToJs.cjs && node scripts/setEnvFile.cjs Release && cd android && ./gradlew clean && ./gradlew assembleRelease",
"open": "open ./android/app/build/outputs/apk/release/",
"strings": "node scripts/stringTypes.cjs",
"prepare": "husky install"
"prepare": "husky install",
"cssToJs": "node scripts/convertCssToJs.cjs"
},
"dependencies": {
"@cd-z/react-native-epub-creator": "^2.0.4",
"@cd-z/epub-constructor": "^3.0.1",
"@cd-z/react-native-epub-creator": "^3.0.0",
"@gorhom/bottom-sheet": "^4.4.5",
"@react-native-community/slider": "^4.4.2",
"@react-native-cookies/cookies": "^6.2.1",
Expand Down Expand Up @@ -51,6 +53,7 @@
"react-native-device-info": "^8.4.7",
"react-native-drawer-layout": "^3.2.2",
"react-native-error-boundary": "^1.1.16",
"react-native-file-access": "^3.1.0",
"react-native-gesture-handler": "~2.12.0",
"react-native-lottie-splash-screen": "^1.0.1",
"react-native-mmkv": "^2.11.0",
Expand Down
29 changes: 29 additions & 0 deletions scripts/convertCssToJs.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const fs = require('fs');
const path = require('path');

const cssFilePath = path.resolve(
__dirname + '/../android/app/src/main/assets/css/',
'index.css',
);
const jsFilePath = path.resolve(
__dirname + '/../android/app/src/main/assets/css/',
'index.js',
);

fs.readFile(cssFilePath, 'utf8', (err, data) => {
if (err) {
console.error('Error reading CSS file:', err);
return;
}

const jsContent = `export default \`\n${data}\n\`;`;

fs.writeFile(jsFilePath, jsContent, 'utf8', err => {
if (err) {
console.error('Error writing JS file:', err);
return;
}

console.info('CSS file successfully converted to JS module.');
});
});
19 changes: 15 additions & 4 deletions src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,21 @@ const InfoItem = ({
title,
icon = 'information-outline',
theme,
paddingHorizontal = 16,
}: {
title: string;
icon?: string;
theme: ThemeColors;
paddingHorizontal?: number;
}) => (
<View style={styles.infoCtn}>
<MaterialIcon size={20} color={theme.onSurfaceVariant} name={icon} />
<View style={[styles.infoCtn, { paddingHorizontal }]}>
<MaterialIcon
size={20}
color={theme.onSurfaceVariant}
name={icon}
style={{ width: 20 }}
/>

<Text style={[styles.infoMsg, { color: theme.onSurfaceVariant }]}>
{title}
</Text>
Expand Down Expand Up @@ -159,10 +167,13 @@ const styles = StyleSheet.create({
},
infoCtn: {
paddingVertical: 12,
paddingHorizontal: 16,
// paddingHorizontal: 16,
display: 'flex',
flexDirection: 'row',
},
infoMsg: {
marginTop: 12,
marginLeft: 6,
verticalAlign: 'middle',
fontSize: 12,
},
iconCtn: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { Modal, TextInput, Text } from 'react-native-paper';
import { Modal, TextInput, Text } from 'react-native-paper'; //@ts-ignore
import { openDocumentTree } from 'react-native-saf-x';

import { Button, List, SwitchItem } from '@components';
Expand Down Expand Up @@ -99,12 +99,14 @@ const ChooseEpubLocationModal: React.FC<ChooseEpubLocationModalProps> = ({
value={useAppTheme.value}
onPress={useAppTheme.toggle}
theme={theme}
style={styles.switch}
/>
<SwitchItem
label={getString('novelScreen.convertToEpubModal.useCustomCSS')}
value={useCustomCSS.value}
onPress={useCustomCSS.toggle}
theme={theme}
style={styles.switch}
/>
<SwitchItem
label={getString('novelScreen.convertToEpubModal.useCustomJS')}
Expand All @@ -114,11 +116,13 @@ const ChooseEpubLocationModal: React.FC<ChooseEpubLocationModalProps> = ({
value={useCustomJS.value}
onPress={useCustomJS.toggle}
theme={theme}
style={styles.switch}
/>
</View>
<List.InfoItem
title={getString('novelScreen.convertToEpubModal.chaptersWarning')}
theme={theme}
paddingHorizontal={20}
/>
<View style={styles.modalFooterCtn}>
<Button title={getString('common.submit')} onPress={onSubmit} />
Expand All @@ -136,19 +140,18 @@ const styles = StyleSheet.create({
borderRadius: 32,
},
settings: {
marginTop: 12,
padding: 24,
paddingBottom: 24,
},
switch: {
paddingHorizontal: 20,
},
modalHeaderCtn: {
padding: 20,
paddingTop: 32,
paddingBottom: 0,
},
modalFooterCtn: {
flexDirection: 'row-reverse',
paddingHorizontal: 20,
padding: 20,
paddingTop: 8,
paddingBottom: 20,
},
modalTitle: {
fontSize: 24,
Expand Down
Loading

0 comments on commit e6e6072

Please sign in to comment.