Skip to content
Open
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
2 changes: 1 addition & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ android {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 14
versionName "1.0.1"
versionName "1.0.2"
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()

if (isNewArchitectureEnabled()) {
Expand Down
1 change: 0 additions & 1 deletion assets/icons8-trash-32.svg

This file was deleted.

Binary file added assets/images/appLogoImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions libraries/requester/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import Axios from "axios";

interface IRequester {
get: (url: string, options?: object) => Promise<any>;
post: (url: string, data?: object, headers?: object, timeoutMS?: number) => Promise<any>;
}

class Requester implements IRequester {
Expand All @@ -18,6 +21,42 @@ class Requester implements IRequester {
}
}

post = async (url: string, data?: object, headers?: object, timeoutMS?: number): Promise<any> => {
try {
const config: any = {
method: 'POST',
headers: {
'Cache-Control': 'no-cache',
'Content-Type': 'application/json',
},
url,
timeout: timeoutMS || 60000
};
headers && (config.headers = headers);
data && (config.data = JSON.stringify(data));
const response = await Axios(config);
return { data: response.data, status: response.status };
} catch (error) {
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
console.log(error.response.data);
console.log(error.response.status);
console.log(error.response.headers);
} else if (error.request) {
// The request was made but no response was received
// `error.request` is an instance of XMLHttpRequest in the browser and an instance of
// http.ClientRequest in node.js
console.log(error.request);
} else {
// Something happened in setting up the request that triggered an Error
console.log('Error', error.message);
}
console.warn('AxiosRequester -> post: ', error.message);
return error?.response?.data || error;
}
}

}

export const requester = new Requester();
5 changes: 4 additions & 1 deletion modules/currencies/presenter/useInitCurrency.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { notificationHandler } from "../../../libraries/notificationService/Noti
import { useNavigation } from "@react-navigation/native";
import { StackNavigationProp } from "@react-navigation/stack";
import { notificationsModel } from "../../shared/entities/notifications/Notifications";
import { purchaseModel } from "../../shared/entities/purchase/purchaseModel";

export const useInitCurrency = () => {
const navigation = useNavigation<StackNavigationProp<any>>();
Expand All @@ -30,7 +31,9 @@ export const useInitCurrency = () => {
const currentNotification = notificationsModel.notificationsList.find(item => item.numberId === notification?.data?.id)
if (currentNotification) {
notificationsModel.chosenNotification = currentNotification;
navigation.navigate('ADD_NOTIFICATIONS')
if (purchaseModel.isFreePeriod || purchaseModel.purchaseHistory?.length) {
navigation.navigate('ADD_NOTIFICATIONS')
}
};
} catch (error) {
console.warn('NotificationService -> onReceiveNotification: ', error);
Expand Down
3 changes: 2 additions & 1 deletion modules/currencies/ui/ConvectorScreen/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useUiContext } from '../../../../src/UIProvider';
import { calculatorModel } from '../../../shared/entities/calculator/Calculator';
import { ratesModel } from '../../../shared/entities/rates/Rates';
import { AdBanner } from '../../../shared/ui/adBanner';
import { useVersionControl } from '../../../versionControl/presenter/useVersionControl';
import { useInitCurrency } from '../../presenter/useInitCurrency';
import { ButtonsConvectorBlock } from '../components/buttonsConvectorBlock';
import { CurrencyRowMain } from '../components/currencyRowMain';
Expand All @@ -19,7 +20,7 @@ interface IProps {
export const ConvectorScreen: FC<IProps> = observer(({ navigation }) => {
const { colors } = useUiContext();
const styles = useMemo(() => getStyle(colors), [colors]);

useVersionControl();
useInitCurrency();

const goToCurrencyList = () => {
Expand Down
2 changes: 1 addition & 1 deletion modules/currencies/ui/ConvectorScreen/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ export const getStyle = (colors: IColors) => {
},
});
return styles;
}
}
38 changes: 21 additions & 17 deletions modules/currencies/ui/components/headerMain/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ export const HeaderMain: FC = observer(() => {
}
}, [connected]);

useEffect(() => {
if (purchaseModel.isPurchased) {
setIsPaymentVisible(false);
}
}, [purchaseModel.isPurchased]);

useEffect(() => {
const interval = setInterval(() => {
rotate.value = withSequence(
Expand Down Expand Up @@ -72,32 +78,32 @@ export const HeaderMain: FC = observer(() => {
}, []);

const onPressNotifications = () => {
if ((purchaseModel.isFreePeriod && purchaseModel.isHideTrialPeriod) || purchaseModel.purchaseHistory?.length) {
if (isConnected) {
if (isConnected) {
if (purchaseModel.isPurchased) {
setEmptyNotification()
if (notificationsModel.notificationsList.length === 0) {
navigation.navigate('ADD_NOTIFICATIONS');
} else {
navigation.navigate('NOTIFICATIONS');
}
} else {
showToast();
onOpenModal();
}
} else {
onOpenModal();
showToast();
}
};

const useTrialPeriod = () => {
purchaseModel.isHideTrialPeriod = true;
setEmptyNotification()
if (notificationsModel.notificationsList.length === 0) {
navigation.navigate('ADD_NOTIFICATIONS');
} else {
navigation.navigate('NOTIFICATIONS');
}
onCloseModal();
}
// const useTrialPeriod = () => {
// purchaseModel.isHideTrialPeriod = true;
// setEmptyNotification()
// if (notificationsModel.notificationsList.length === 0) {
// navigation.navigate('ADD_NOTIFICATIONS');
// } else {
// navigation.navigate('NOTIFICATIONS');
// }
// onCloseModal();
// }

return (
<View style={styles.container}>
Expand All @@ -114,10 +120,8 @@ export const HeaderMain: FC = observer(() => {
visible={isPaymentVisible}
onCancel={onCloseModal}
onPurchase={purchaseNotifications}
onConfirm={useTrialPeriod}
text={purchaseModel.isFreePeriod ? t('setCourseLimits') : t('freePeriodIsOver')}
purchaseText={t('buyService')}
confirmText={purchaseModel.isHideTrialPeriod ? '' : t('yseTrialPeriod')}
purchaseText={purchaseModel.isFreePeriod ? t('yseTrialPeriod') : t('buyService')}
/>
</View >
);
Expand Down
26 changes: 26 additions & 0 deletions modules/shared/entities/appVersion/AppVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { IStorage, storage } from "../../../../libraries/storage";
import { MobXRepository } from "../../../../src/store/MobXRepository";
import { IAppVersion } from "./IAppVersion";

export interface IAppVersionModel {

}

class AppVersionModel implements IAppVersionModel {
private appVersionStore = new MobXRepository<IAppVersion | null>(null);

constructor(private storage: IStorage) {

}

get appVersion() {
return this.appVersionStore.data || null;
}

set appVersion(data: IAppVersion | null) {
this.appVersionStore.save(data)
}

}

export const appVersionModel = new AppVersionModel(storage);
6 changes: 6 additions & 0 deletions modules/shared/entities/appVersion/IAppVersion.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export interface IAppVersion {
minAndroidVersion: string;
minIosVersion: string;
recommendedAndroidVersion: string;
recommendedIosVersion: string;
}
41 changes: 27 additions & 14 deletions modules/shared/entities/purchase/purchaseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,48 +2,53 @@ import { IStorage, storage } from "../../../../libraries/storage";
import { MobXRepository } from "../../../../src/store/MobXRepository";
// @ts-ignore
import AppInstallDate from 'react-native-app-install-date';
import moment from "moment";

export interface IPurchaseModel {
isFreePeriod: boolean;
isHideTrialPeriod: boolean;
purchaseHistory: any[];
isPurchased: boolean;
}

const FREE_PERIOD_DAYS = 3;
// const FREE_PERIOD_DAYS = 3;

class PurchaseModel implements IPurchaseModel {
private isHideTrialPeriodRepository = new MobXRepository<boolean>(false);
private isFreePeriodRepository = new MobXRepository<boolean>(false);
private purchaseHistoryRepository = new MobXRepository<any>(false);
private isPurchasedRepository = new MobXRepository<any>(false);

constructor(private storage: IStorage) {
this.load();
this.getIsFreePeriod();
// this.getIsFreePeriod();
}

private load = () => {
this.storage.get('PURCHASE_HISTORY')
.then(data => { data && this.purchaseHistoryRepository.save(data); })
.catch(error => console.warn('PurchaseModel -> PURCHASE_HISTORY: ', error));
this.storage.get('SHOW_TRIAL_PERIOD')
.then(data => { data && this.isHideTrialPeriodRepository.save(data); })
.catch(error => console.warn('PurchaseModel -> SHOW_TRIAL_PERIOD: ', error));
// this.storage.get('SHOW_TRIAL_PERIOD')
// .then(data => { data && this.isHideTrialPeriodRepository.save(data); })
// .catch(error => console.warn('PurchaseModel -> SHOW_TRIAL_PERIOD: ', error));
}

getIsFreePeriod = async () => {
const instalTime = await AppInstallDate.getDateTime('yyyy/MM/dd HH:mm');
const instalTimeUnix = new Date(instalTime);
instalTimeUnix.setDate(instalTimeUnix.getDate() + FREE_PERIOD_DAYS);
if (instalTimeUnix.getTime() > Date.now()) {
this.isFreePeriodRepository.save(true);
}
}
// getIsFreePeriod = async () => {
// const instalTime = await AppInstallDate.getDateTime('yyyy/MM/dd HH:mm');
// const instalTimeUnix = new Date(instalTime);
// instalTimeUnix.setDate(instalTimeUnix.getDate() + FREE_PERIOD_DAYS);
// if (instalTimeUnix.getTime() > Date.now()) {
// this.isFreePeriodRepository.save(true);
// }
// }

get isFreePeriod() {
return this.isFreePeriodRepository.data ?? false;
}

set isFreePeriod(data: boolean) {
this.isFreePeriodRepository.save(data);
}

get purchaseHistory() {
return this.purchaseHistoryRepository.data ?? [];
}
Expand All @@ -62,6 +67,14 @@ class PurchaseModel implements IPurchaseModel {
this.storage.set('SHOW_TRIAL_PERIOD', data);
}

get isPurchased() {
return this.isPurchasedRepository.data ?? false;
}

set isPurchased(data: boolean) {
this.isPurchasedRepository.save(data);
}

}

export const purchaseModel = new PurchaseModel(storage);
2 changes: 1 addition & 1 deletion modules/shared/hooks/useDebounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ export const useDebounce = (callback: Function, delay: number) => {
}, [callback, delay]);

return { debouncedWrapper };
};
};
Loading