Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16,394 changes: 16,394 additions & 0 deletions wowsinfo/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,13 @@ import {List} from 'react-native-paper';
import {lang} from '../../value/lang';
import {SafeAction} from '../../core';

interface AdmobBannerState {
success: boolean;
}

// mark as deprecated
class AdmobBanner extends Component {
constructor(props) {
class AdmobBanner extends Component<{}, AdmobBannerState> {
constructor(props: {}) {
super(props);
this.state = {
success: true,
Expand All @@ -24,7 +28,7 @@ class AdmobBanner extends Component {
}

hideAds = () => this.setState({success: false});
logError = err => {
logError = (err: any) => {
console.log('err', err);
this.setState({success: false});
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import {lang} from '../../value/lang';
import {APP} from '../../value/data';
import {SimpleViewHandler} from '../../core/native/SimpleViewHandler';

// Declare global AppGlobalData
declare const AppGlobalData: {
githubVersion: boolean;
};

// Now, we have 4 tiers ($1, $3, $5 and $10) for donations
const itemSkus = [
'com.yihengquan.wowsinfo.support1',
Expand All @@ -14,8 +19,21 @@ const itemSkus = [
'com.yihengquan.wowsinfo.support10',
];

class Donation extends Component {
constructor(props) {
interface SupportItem {
t: string;
d: string;
c: string;
}

interface DonationState {
products: RNIap.Product[] | null;
receipt?: string;
}

class Donation extends Component<{}, DonationState> {
support: SupportItem[] = [];

constructor(props: {}) {
super(props);
this.state = {
products: null,
Expand All @@ -37,7 +55,6 @@ class Donation extends Component {
}

render() {
const {products} = this.state;
console.log(this.state);

this.support = [
Expand Down Expand Up @@ -79,7 +96,7 @@ class Donation extends Component {
);
}

async supportWoWsInfo(item) {
async supportWoWsInfo(item: RNIap.Product) {
try {
// Will return a purchase object with a receipt which can be used to validate on your server.
const purchase = await RNIap.buyProduct(item.productId);
Expand All @@ -88,13 +105,13 @@ class Donation extends Component {
this.setState({
receipt: purchase.transactionReceipt, // save the receipt if you need it, whether locally, or to your server.
});
} catch (err) {
} catch (err: any) {
// standardized err.code and err.message available
console.error(err.code, err.message);
const subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(
async purchase => {
async (purchase: RNIap.Purchase) => {
this.setState({receipt: purchase.transactionReceipt}, () =>
this.goToNext(),
(this as any).goToNext(),
);
subscription.remove();
},
Expand Down
2 changes: 1 addition & 1 deletion wowsinfo/src/component/common/FooterButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React from 'react';
import {SafeAreaView} from 'react-native';
import {IconButton, Colors} from 'react-native-paper';
import {Actions} from 'react-native-router-flux';
Expand Down
2 changes: 1 addition & 1 deletion wowsinfo/src/component/common/InfoLabel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Touchable} from './Touchable';

export interface InfoLabelProps {
title: string;
info: string;
info: string | number | undefined;
left?: boolean;
right?: boolean;
style?: any;
Expand Down
63 changes: 0 additions & 63 deletions wowsinfo/src/component/common/PlayerCell.js

This file was deleted.

82 changes: 82 additions & 0 deletions wowsinfo/src/component/common/PlayerCell.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/**
* PlayerCell.tsx
*
* Display player and clan with their ID at the right
*/

import React, {Component} from 'react';
import {StyleSheet} from 'react-native';
import {List, Caption, Text} from 'react-native-paper';
import {SafeAction} from '../../core';

interface PlayerItem {
nickname: string;
account_id: number;
}

interface ClanItem {
tag: string;
clan_id: number;
}

interface PlayerCellProps {
item: PlayerItem | ClanItem;
player?: boolean;
clan?: boolean;
width?: number;
}

class PlayerCell extends Component<PlayerCellProps> {
render() {
const {item, player, clan, width} = this.props;

if (player) {
const playerItem = item as PlayerItem;
return (
<List.Item
title={playerItem.nickname}
style={{width: width}}
right={() => this.renderPlayerRight(playerItem.account_id)}
onPress={() => this.pushPlayer(playerItem)}
/>
);
} else if (clan) {
const clanItem = item as ClanItem;
return (
<List.Item
title={clanItem.tag}
style={{width: width}}
right={() => this.renderClanRight(clanItem.clan_id)}
onPress={() => this.pushClan(clanItem)}
/>
);
} else {
return <Text>???</Text>;
}
}

renderPlayerRight(account_id: number) {
return <Caption style={styles.ID}>{account_id}</Caption>;
}

renderClanRight(clan_id: number) {
return <Caption style={styles.ID}>{clan_id}</Caption>;
}

pushPlayer(item: PlayerItem) {
SafeAction('Statistics', {info: item});
}

pushClan(item: ClanItem) {
SafeAction('ClanInfo', {info: item});
}
}

const styles = StyleSheet.create({
ID: {
alignSelf: 'center',
marginRight: 8,
},
});

export {PlayerCell};
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
/**
* SafeView.js
* SafeView.tsx
*
* Wrap view around SafeAreView and Surface
*/

import React, {Component} from 'react';
import {SafeAreaView, StyleSheet} from 'react-native';
import React, {Component, ReactNode} from 'react';
import {SafeAreaView, StyleSheet, ViewStyle} from 'react-native';
import {Surface} from 'react-native-paper';

class SafeView extends Component {
interface SafeViewProps {
theme?: any;
style?: ViewStyle;
children?: ReactNode;
}

class SafeView extends Component<SafeViewProps> {
render() {
const {theme, style, children} = this.props;
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
/**
* Space.js
* Space.tsx
*
* Add space to component
*/

import React, {Component} from 'react';
import {View, StyleSheet} from 'react-native';
import {View} from 'react-native';
import {SafeValue} from '../../core';

class Space extends Component {
interface SpaceProps {
height?: number;
}

class Space extends Component<SpaceProps> {
render() {
const {height} = this.props;

// Default value is 128
let h = SafeValue(height, 128);
const h = SafeValue(height, 128);

return <View style={{height: h}} />;
}
}

const styles = StyleSheet.create({});

export {Space};
File renamed without changes.
Loading