Skip to content

Commit

Permalink
realease version 0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hashiqi12138 committed May 5, 2021
1 parent e6c75d2 commit 55f95d2
Show file tree
Hide file tree
Showing 58 changed files with 3,403 additions and 3,112 deletions.
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Windows files
[*.bat]
end_of_line = crlf
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.pbxproj -text
# Windows files should use crlf line endings
# https://help.github.com/articles/dealing-with-line-endings/
*.bat text eol=crlf
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ build/
local.properties
*.iml

# Visual Studio Code
#
.vscode/

# node.js
#
node_modules/
Expand Down
1 change: 1 addition & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ module.exports = {
jsxBracketSameLine: true,
singleQuote: true,
trailingComma: 'all',
arrowParens: 'avoid',
};
203 changes: 100 additions & 103 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,111 +8,108 @@
* @format
*/

import React from 'react';
import {
SafeAreaView,
StyleSheet,
ScrollView,
View,
Text,
StatusBar,
} from 'react-native';
import React from 'react';
import {
SafeAreaView,
ScrollView,
StatusBar,
StyleSheet,
Text,
useColorScheme,
View,
} from 'react-native';

import {
Header,
LearnMoreLinks,
Colors,
DebugInstructions,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';
import {
Colors,
DebugInstructions,
Header,
LearnMoreLinks,
ReloadInstructions,
} from 'react-native/Libraries/NewAppScreen';

declare const global: {HermesInternal: null | {}};
const Section: React.FC<{
title: string;
}> = ({children, title}) => {
const isDarkMode = useColorScheme() === 'dark';
return (
<View style={styles.sectionContainer}>
<Text
style={[
styles.sectionTitle,
{
color: isDarkMode ? Colors.white : Colors.black,
},
]}>
{title}
</Text>
<Text
style={[
styles.sectionDescription,
{
color: isDarkMode ? Colors.light : Colors.dark,
},
]}>
{children}
</Text>
</View>
);
};

const App = () => {
return (
<>
<StatusBar barStyle="dark-content" />
<SafeAreaView>
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={styles.scrollView}>
<Header />
{global.HermesInternal == null ? null : (
<View style={styles.engine}>
<Text style={styles.footer}>Engine: Hermes</Text>
</View>
)}
<View style={styles.body}>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Step One</Text>
<Text style={styles.sectionDescription}>
Edit <Text style={styles.highlight}>App.tsx</Text> to change
this screen and then come back to see your edits.
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>See Your Changes</Text>
<Text style={styles.sectionDescription}>
<ReloadInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Debug</Text>
<Text style={styles.sectionDescription}>
<DebugInstructions />
</Text>
</View>
<View style={styles.sectionContainer}>
<Text style={styles.sectionTitle}>Learn More</Text>
<Text style={styles.sectionDescription}>
Read the docs to discover what to do next:
</Text>
</View>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
</>
);
};
const App = () => {
const isDarkMode = useColorScheme() === 'dark';

const styles = StyleSheet.create({
scrollView: {
backgroundColor: Colors.lighter,
},
engine: {
position: 'absolute',
right: 0,
},
body: {
backgroundColor: Colors.white,
},
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
color: Colors.black,
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
color: Colors.dark,
},
highlight: {
fontWeight: '700',
},
footer: {
color: Colors.dark,
fontSize: 12,
fontWeight: '600',
padding: 4,
paddingRight: 12,
textAlign: 'right',
},
});
const backgroundStyle = {
backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
};

export default App;
return (
<SafeAreaView style={backgroundStyle}>
<StatusBar barStyle={isDarkMode ? 'light-content' : 'dark-content'} />
<ScrollView
contentInsetAdjustmentBehavior="automatic"
style={backgroundStyle}>
<Header />
<View
style={{
backgroundColor: isDarkMode ? Colors.black : Colors.white,
}}>
<Section title="Step One">
Edit <Text style={styles.highlight}>App.js</Text> to change this
screen and then come back to see your edits.
</Section>
<Section title="See Your Changes">
<ReloadInstructions />
</Section>
<Section title="Debug">
<DebugInstructions />
</Section>
<Section title="Learn More">
Read the docs to discover what to do next:
</Section>
<LearnMoreLinks />
</View>
</ScrollView>
</SafeAreaView>
);
};

const styles = StyleSheet.create({
sectionContainer: {
marginTop: 32,
paddingHorizontal: 24,
},
sectionTitle: {
fontSize: 24,
fontWeight: '600',
},
sectionDescription: {
marginTop: 8,
fontSize: 18,
fontWeight: '400',
},
highlight: {
fontWeight: '700',
},
});

export default App;
6 changes: 3 additions & 3 deletions App/API/BasicRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import getTokenHeader from './encoder';
import decode from './decoder';
import {API_VERSION, BASE_CDN_YD_URL} from './APIConstant';

export const getAlbumPostUrl = (albumId: string): string => {
export const getAlbumPosterUrl = (albumId: string): string => {
return `${BASE_CDN_YD_URL}/media/albums/${albumId}_3x4.jpg`;
};

Expand All @@ -22,7 +22,7 @@ export interface I_API {
export class API implements I_API {
app_version: string = API_VERSION;

GET(url: string, query?: object, config?: RequestInit): Promise<any> {
async GET(url: string, query?: object, config?: RequestInit): Promise<any> {
let queryParams = '';
if (query) {
queryParams += '?key=0b931a6f4b5ccc3f8d870839d07ae7b2';
Expand Down Expand Up @@ -54,7 +54,7 @@ export class API implements I_API {
});
}

POST(url: string, query?: object, config?: RequestInit): Promise<any> {
async POST(url: string, query?: object, config?: RequestInit): Promise<any> {
let queryParams = '';
if (query) {
for (let key in query) {
Expand Down
19 changes: 13 additions & 6 deletions App/API/Comic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@ import {API_ABILITY} from './APIConstant';

const GetLatestComic = async (): Promise<Array<any>> => {
const latest = await API.GET(API_ABILITY.API_COMIC_LATEST).catch(() => {
return [];
},
);
return [];
});
return latest;
};

const GetComicDetail = async (albumId: string): Promise<any> => {
function sortBy(name: string, name_second: string) {
const number = parseInt(name.split('.')[0]);
const secondNum = parseInt(name_second.split('.')[0]);
const number = parseInt(name.split('.')[0], 10);
const secondNum = parseInt(name_second.split('.')[0], 10);
return number - secondNum;
}
const detail = await API.GET(API_ABILITY.API_COMIC_DETAIL, {
Expand Down Expand Up @@ -47,4 +46,12 @@ const GetComicChapter = async (series_id: string) => {
return detail;
};

export {GetLatestComic, GetComicDetail, GetComicChapter};
const getRandomComic = async () => {
const random = await API.GET(API_ABILITY.API_COMIC_LATEST).catch((err) => {
console.error(err);
return [];
});
return random;
};

export {GetLatestComic, GetComicDetail, GetComicChapter, getRandomComic};
15 changes: 11 additions & 4 deletions App/ComicReader/SingleImage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import React, {useEffect, useState} from 'react';
import {Image, StyleSheet, Dimensions} from 'react-native';
import {NativeModules} from 'react-native';
// import FastImage from 'react-native-fast-image';
import {getPhotoUrl} from '../API/BasicRequest';
import JMImage from '../Comic/JMImage';

const ScrambleId = 220980;

interface ImageInfo {
Expand Down Expand Up @@ -45,11 +44,11 @@ function SingleImage({album, photo}) {
height: size.height,
},
});
const shouldScramble = parseInt(album) > ScrambleId;
const shouldScramble = parseInt(album, 10) > ScrambleId;
useEffect(() => {
requestDecodeImage(photo_url, shouldScramble)
.then((info) => {
console.log(album, shouldScramble);
console.log(album, shouldScramble, info);
console.log('scramble image', info);
info.filePath = 'file://' + info.filePath;
setBase(info.filePath);
Expand All @@ -64,6 +63,14 @@ function SingleImage({album, photo}) {
});
}, [album, photo_url, shouldScramble, width]);
return (
// <FastImage
// style={style.image}
// source={{
// uri: filePath,
// priority: FastImage.priority.normal,
// }}
// resizeMode={FastImage.resizeMode.contain}
// />
<Image
style={style.image}
source={{
Expand Down
5 changes: 2 additions & 3 deletions App/ComicView/ComicView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import {SafeAreaView, FlatList, StyleSheet} from 'react-native';
import {useEffect, useState} from 'react';
import {GetLatestComic} from '../API/Comic';
import ComicItem from './ComicItem';
import {getAlbumPostUrl} from '../API/BasicRequest';

import {getAlbumPosterUrl} from '../API/BasicRequest';

const styles = StyleSheet.create({
container: {
Expand All @@ -30,7 +29,7 @@ function LatestComicScreen({navigation}) {
GetLatestComic().then((res) => {
console.log('latest >>> ', res);
res.forEach((comic) => {
comic.image = getAlbumPostUrl(comic.id);
comic.image = getAlbumPosterUrl(comic.id);
});
// @ts-ignore
setData(res);
Expand Down
Loading

0 comments on commit 55f95d2

Please sign in to comment.