Skip to content

Commit

Permalink
Merge pull request #23 from markxoe/feature/multiplyPrices
Browse files Browse the repository at this point in the history
Feature/multiply prices
  • Loading branch information
markxoe authored Jan 25, 2021
2 parents c423f2c + a13efd4 commit 03ac87d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/globals.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { stateType } from "./store/types";
import Axios from "axios";
import packagejs from "../package.json"
import packagejs from "../package.json";
import calculateHeader from "./functions/calculateauthorization";
import { getPlatforms } from "@ionic/react";



export const rotateSpeedLevel = {
max: 3,
levels: [
Expand All @@ -31,7 +29,8 @@ export const getAdditionalBeePrice = (state: stateType): number => {
state.biene.additionalBienen.length +
state.biene.multiplierLevel +
state.biene.autoRotatingBees.length
)
) *
(state.settings.multiplyPrices ? 10.0 : 1.0)
);
};
export const getMultiplierPrice = (state: stateType): number => {
Expand Down Expand Up @@ -187,7 +186,7 @@ export const uploadData = (state: stateType) => {
data.additionalBeeLength
),
version: packagejs.version,
platforms: getPlatforms().join(" ")
platforms: getPlatforms().join(" "),
},
}
)
Expand Down
10 changes: 10 additions & 0 deletions src/pages/Settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
ActionSettingsSetClickButtonForBee,
ActionSettingsSetNewUI,
ActionSettingSetNameAtHomePosition,
ActionSetMultiplyPrices,
} from "../store/Actions";

import { Plugins, Storage } from "@capacitor/core";
Expand Down Expand Up @@ -187,6 +188,15 @@ const PageSettings: React.FC = () => {
</IonItem>
<IonItemDivider>Allgemein</IonItemDivider>

<IonItem>
<IonLabel>Höhere Preise</IonLabel>
<IonToggle
checked={state.settings.multiplyPrices}
onIonChange={(e) => {
dispatch(ActionSetMultiplyPrices(e.detail.checked));
}}
/>
</IonItem>
<IonItem>
<IonLabel>Neues User Interface</IonLabel>
<IonToggle
Expand Down
14 changes: 14 additions & 0 deletions src/pages/Store.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ import {
IonToast,
IonToolbar,
useIonViewDidEnter,
IonItem,
IonToggle,
IonLabel,
} from "@ionic/react";
import { AppContext } from "../store/State";
import {
Expand All @@ -43,6 +46,7 @@ import {
ActionMultiplierIncrease,
ActionRotateSpeedLevelIncrease,
ActionSetState,
ActionSetMultiplyPrices,
} from "../store/Actions";
import { RefresherEventDetail } from "@ionic/core";
import { flashOutline } from "ionicons/icons";
Expand Down Expand Up @@ -444,6 +448,16 @@ const StorePage: React.FC = () => {
</IonCardContent>
</IonCard>

<IonItem>
<IonLabel>Höhere Preise</IonLabel>
<IonToggle
checked={state.settings.multiplyPrices}
onIonChange={(e) => {
dispatch(ActionSetMultiplyPrices(e.detail.checked));
}}
/>
</IonItem>

<IonToast
isOpen={showThx}
translucent
Expand Down
5 changes: 5 additions & 0 deletions src/store/Actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,8 @@ export const ActionAddGoldenBiene = (): actionType => ({
export const ActionResetManyThings = (): actionType => ({
type: "resetManyThings",
});

export const ActionSetMultiplyPrices = (activated: boolean): actionType => ({
type: "setMultiplyPrices",
payload: activated,
});
11 changes: 11 additions & 0 deletions src/store/State.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const initialState: stateType = {
newUI: true,
deactivateStoreConfetti: false,
nameathomeposition: nameAtHomePositions.top,
multiplyPrices: false,
},
statisticsRotations: 0,
settingMaxNumberDisplayedBees: 20,
Expand Down Expand Up @@ -205,6 +206,16 @@ let reducer = (state: stateType, action: actionType): stateType => {
},
};
}

case "setMultiplyPrices": {
return {
...state,
settings: {
...state.settings,
multiplyPrices: action.payload,
},
};
}
}

return state;
Expand Down
1 change: 1 addition & 0 deletions src/store/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface stateType {
newUI: boolean;
deactivateStoreConfetti: boolean;
nameathomeposition: nameAtHomePositions;
multiplyPrices: boolean;
};
statisticsRotations: number;
settingMaxNumberDisplayedBees: number;
Expand Down

0 comments on commit 03ac87d

Please sign in to comment.