How to use unlockMethod method in Appium Android Driver

Best JavaScript code snippet using appium-android-driver

potslot.js

Source:potslot.js Github

copy

Full Screen

1/**2 * Module description3 * @moduleName PotSlot4 * @snippet PotSlot.snippet5PotSlot({6 potskin: potskin,7 onClick: function () {}8})9 */10bento.define('ui/potslot', [11 'bento',12 'bento/math/vector2',13 'bento/math/rectangle',14 'bento/components/sprite',15 'bento/components/clickable',16 'bento/entity',17 'bento/eventsystem',18 'bento/gui/clickbutton',19 'bento/gui/counter',20 'bento/gui/text',21 'bento/utils',22 'bento/tween',23 'components/spritecontainer',24 'modules/timemanager',25 'components/sortedclickable',26 'globals',27 'modules/skinmanager',28 'ui/potunlockeddialog',29 'modules/savemanager',30 'modules/ads',31 'modules/localization',32 'ui/vipdialog',33 'ui/shopdialog'34], function (35 Bento,36 Vector2,37 Rectangle,38 Sprite,39 Clickable,40 Entity,41 EventSystem,42 ClickButton,43 Counter,44 Text,45 Utils,46 Tween,47 SpriteContainer,48 TimeManager,49 SortedClickable,50 Globals,51 SkinManager,52 PotUnlockedDialog,53 SaveManager,54 Ads,55 Localization,56 VipDialog,57 ShopDialog58) {59 'use strict';60 return function (settings) {61 // --- PARAMETERS ---62 var index = settings.index || 0;63 var skin = settings.skin;64 var onClick = settings.onClick || function () {};65 var onStateChanged = settings.onStateChanged || function () {};66 var isScrolling = settings.isScrolling || function () {67 return false;68 };69 var lastCoinCount = 0;70 var coinCount = SaveManager.load('coinCount');71 var unlockMethod = SkinManager.getPotSkinUnlockMethod(skin);72 var unlockMethodValue = unlockMethod.value;73 var purchaseCost = unlockMethodValue;74 if (SkinManager.getAllUnlockedPotSkins().length < 2 && unlockMethod.method === "coins") {75 //unlockMethodValue = 0;76 }77 var canBuy = function () {78 return (coinCount >= purchaseCost);79 };80 var updateCoinValue = function () {81 coinCount = SaveManager.load('coinCount');82 };83 // --- COMPONENTS ---84 var unlockedStuff = new Entity({85 name: 'unlockedStuff',86 position: new Vector2(0, 0),87 boundingBox: new Rectangle(-22, -22, 44, 44),88 components: [89 new SpriteContainer({90 name: 'buttonSpriteContainer',91 imageName: 'ui/char-back-unlocked2',92 originRelative: new Vector2(0.5, 0.5),93 position: new Vector2(0, 0),94 scale: Globals.pixelScaleUIV95 }),96 new SpriteContainer({97 name: 'buttonIcon',98 spriteSheet: 'potskins/' + skin,99 originRelative: new Vector2(0.5, 0.5),100 position: new Vector2(0, -16),101 scale: Globals.pixelScaleV.scalarMultiply(1.75)102 }),103 new SortedClickable({104 onClick: function (data) {105 if (!isScrolling()) {106 onClick();107 Bento.audio.playSound('sfx_clickbutton');108 }109 }110 })111 ]112 });113 var purchaseButton = new ClickButton({114 name: 'purchaseButton',115 sfx: 'sfx_clickbutton',116 sprite: new Sprite({117 imageName: 'ui/greenbutton',118 frameCountX: 1,119 frameCountY: 3,120 originRelative: new Vector2(0.5, 0.5),121 animations: {122 up: {123 frames: [0],124 speed: 0125 },126 down: {127 frames: [1],128 speed: 0129 },130 inactive: {131 frames: [2],132 speed: 0133 }134 }135 }),136 position: new Vector2(0, 12),137 scale: Globals.pixelScaleUIV.scalarMultiply(0.7),138 sort: true,139 onClick: function () {140 if (!isScrolling()) {141 if (canBuy()) {142 Utils.takeCoins(purchaseCost, 'pots', skin);143 Bento.audio.stopSound('sfx_coin_collect_loop');144 EventSystem.fire('GameAnalytics-addDesignEvent', {145 eventId: "potsUnlocked:" + skin146 });147 SkinManager.makePotSkinUnlocked(skin);148 new PotUnlockedDialog({149 potSkin: skin,150 onComplete: function () {151 onStateChanged('unlocked');152 }153 });154 } else {155 new ShopDialog({});156 }157 }158 }159 });160 var coinPurchaseStuff = new Entity({161 name: 'coinPurchaseStuff',162 position: new Vector2(0, 0),163 components: [164 purchaseButton,165 new SpriteContainer({166 imageName: 'coin',167 originRelative: new Vector2(0.5, 0.5),168 position: new Vector2(-11, 12),169 alpha: 1,170 scale: Globals.pixelScaleUIV.scalarMultiply(1),171 rotation: 0172 }),173 new Text({174 fontSettings: Utils.getTextStyle('potPrice'),175 name: 'priceText',176 position: new Vector2(-4, 11),177 text: (purchaseCost > 0) ? purchaseCost.toString() : Localization.getText('free'),178 maxWidth: 22,179 maxHeight: 10180 })181 ]182 });183 var levelUnlockStuff = new Entity({184 name: 'coinPurchaseStuff',185 position: new Vector2(0, 0),186 components: [187 new SpriteContainer({188 imageName: 'ui/lockedlevelbackground',189 originRelative: new Vector2(0.5, 0.5),190 position: new Vector2(0, 10),191 alpha: canBuy ? 1 : 0.5,192 scale: Globals.pixelScaleUIV.multiply(new Vector2(0.35, 0.25)),193 frameCountX: 1,194 frameCountY: 1,195 animations: {196 default: {197 frames: [0],198 speed: 0199 }200 },201 rotation: 0202 }),203 new Text({204 fontSettings: Utils.getTextStyle('potLevel'),205 name: 'levelText',206 position: new Vector2(0, 9.5),207 text: Localization.getText('levelX').replace('{LEVEL}', unlockMethodValue.toString()),208 maxWidth: 32,209 maxHeight: 10210 })211 ]212 });213 var isWatching = false;214 var adIcon = new SpriteContainer({215 imageName: 'ui/icons/vid',216 originRelative: new Vector2(0.5, 0.5),217 position: new Vector2(0, 12),218 alpha: canBuy ? 1 : 0.5,219 scale: Globals.pixelScaleUIV.scalarMultiply(0.4),220 rotation: 0221 });222 var adButton = new ClickButton({223 name: 'adButton',224 sfx: 'sfx_clickbutton',225 sprite: new Sprite({226 imageName: 'ui/orangebutton',227 frameCountX: 1,228 frameCountY: 3,229 originRelative: new Vector2(0.5, 0.5),230 animations: {231 up: {232 frames: [0],233 speed: 0234 },235 down: {236 frames: [1],237 speed: 0238 },239 inactive: {240 frames: [0],241 speed: 0242 }243 }244 }),245 position: new Vector2(0, 12),246 scale: Globals.pixelScaleUIV.scalarMultiply(0.7),247 sort: true,248 onClick: function () {249 var unlockSkin = function () {250 EventSystem.fire('GameAnalytics-addDesignEvent', {251 eventId: "potsUnlocked:" + skin252 });253 SkinManager.makePotSkinUnlocked(skin);254 new PotUnlockedDialog({255 potSkin: skin,256 doAnother: true,257 onComplete: function () {258 onStateChanged('unlocked');259 }260 });261 };262 if (!isScrolling() && !isWatching) {263 if (Utils.isDev()) {264 window.alert("This is a Rewarded Ad!");265 Bento.input.resetPointers();266 unlockSkin();267 } else {268 isWatching = true;269 Ads.showRewarded(function () {270 isWatching = false;271 EventSystem.fire('GameAnalytics-addDesignEvent', {272 eventId: "ads:rewardedSkinUnlockMenu",273 value: 1274 });275 unlockSkin();276 }, function (e) {277 isWatching = false;278 EventSystem.fire('GameAnalytics-addDesignEvent', {279 eventId: "ads:rewardedSkinUnlockMenu",280 value: 0281 });282 }, "SkinUnlockMenu");283 }284 }285 }286 }).attach({287 name: 'rewardedChecker',288 update: function () {289 if (adButton.active && !Ads.canShowRewarded()) {290 adButton.setActive(false);291 adIcon.alpha = 0.5;292 }293 if (!adButton.active && Ads.canShowRewarded()) {294 adButton.setActive(true);295 adIcon.alpha = 1;296 }297 }298 });299 var adUnlockStuff = new Entity({300 name: 'adUnlockStuff',301 position: new Vector2(0, 0),302 components: [303 adButton,304 adIcon305 ]306 });307 var lockedStuff = new Entity({308 name: 'unlockedStuff',309 position: new Vector2(0, 0),310 boundingBox: new Rectangle(-22, -22, 44, 44),311 components: [312 new SpriteContainer({313 name: 'buttonSpriteContainer',314 imageName: 'ui/char-back',315 originRelative: new Vector2(0.5, 0.5),316 position: new Vector2(0, 0),317 scale: Globals.pixelScaleUIV318 }),319 new SpriteContainer({320 name: 'buttonIcon',321 spriteSheet: 'boxes/' + skin,322 originRelative: new Vector2(0.5, 0.5),323 position: new Vector2(0, -10),324 scale: Globals.pixelScaleUIV.scalarMultiply(1.33)325 }),326 ]327 });328 switch (unlockMethod.method) {329 case "coins":330 lockedStuff.attach(coinPurchaseStuff);331 break;332 case "level":333 lockedStuff.attach(levelUnlockStuff);334 break;335 case "ad":336 lockedStuff.attach(adUnlockStuff);337 break;338 }339 // --- ENTITY ---340 var currentState = '';341 var slot = new Entity({342 name: 'slot-' + index,343 position: settings.position || new Vector2(0, 0),344 components: []345 }).extend({346 getState: function () {347 return currentState;348 },349 getSkin: function () {350 return skin;351 }352 });353 // get new state354 currentState = SkinManager.getPotSkinState(skin);355 //attach new stuff356 switch (currentState) {357 case 'locked':358 slot.attach(lockedStuff);359 break;360 case 'unlocked':361 slot.attach(unlockedStuff);362 break;363 }364 // event handler stuff365 slot.attach({366 name: 'eventstuff',367 start: function () {368 EventSystem.on('coinsUpdated', updateCoinValue);369 },370 destroy: function () {371 EventSystem.off('coinsUpdated', updateCoinValue);372 }373 });374 updateCoinValue();375 return slot;376 };...

Full Screen

Full Screen

UnlockScreen.js

Source:UnlockScreen.js Github

copy

Full Screen

1import React from "react";2import {3 Image,4 ScrollView,5 StyleSheet,6 Modal,7 View,8 TouchableOpacity9} from "react-native";10import { connect } from "react-redux";11import PinView from "react-native-pin-view";12import Constants from "expo-constants";13import * as LocalAuthentication from "expo-local-authentication";14import Custom_Text from "../components/shared/Custom_Text";15import Custom_Header from "../components/shared/Custom_Header";16import Custom_HeaderTitle from "../components/shared/Custom_HeaderTitle";17import Custom_HeaderButton from "../components/shared/Custom_HeaderButton";18import Fonts from "../constants/Fonts";19import Colors from "../constants/Colors";20import Images from "../constants/Images";21import Custom_Button from "../components/shared/Custom_Button";22import { authSuccess } from "../actions";23import { isIos } from "../constants/Layout";24class UnlockScreen extends React.Component {25 constructor(props) {26 super(props);27 this.state = {28 codeCreated: false,29 codeMatched: false,30 code: null,31 showCodeError: false,32 availableUnlockMethods: null,33 showModal: false,34 showFailedMessage: false,35 unlockText: "",36 text: "",37 isModalVisible: false,38 showAuthError: false,39 showAuthSuccess: false40 };41 }42 componentDidMount() {43 this.authenticateAsync();44 }45 authenticateAsync = async () => {46 const { unlockMethod, isAuthenticated } = this.props;47 if (unlockMethod !== null && !isAuthenticated) {48 LocalAuthentication.hasHardwareAsync()49 .then(res => {50 if (res) {51 if (unlockMethod === "fingerprint") {52 this.setState({53 unlockText: "Unlock with Fingerprint",54 isModalVisible: true55 });56 } else if (unlockMethod === "faceId") {57 this.setState({58 unlockText: "Unlock with Face ID",59 isModalVisible: true60 });61 }62 this.getUnlockText();63 LocalAuthentication.isEnrolledAsync()64 .then(res => {65 if (res) {66 LocalAuthentication.authenticateAsync()67 .then(res => {68 if (res.success) {69 if (unlockMethod === "fingerprint") {70 this.showAuthSuccess(`Fingerprint \nAuthorized`);71 } else if (unlockMethod === "faceId") {72 this.showAuthSuccess(`Face ID \nAuthorized`);73 }74 this.props.authenticateUser();75 } else {76 if (unlockMethod === "fingerprint") {77 this.showAuthError(`Fingerprint Not \nRecognized`);78 } else if (unlockMethod === "faceId") {79 this.showAuthError(`Face ID Not \nRecognized`);80 }81 }82 })83 .catch(err => console.log("err: ", err));84 } else {85 this.showAuthError(86 `To use this feature you need to first\nset up ${87 availableUnlockMethods === "fingerprint"88 ? "Fingerprint"89 : "Face"90 } on your device.`91 );92 }93 })94 .catch(err => console.log("err: ", err));95 }96 })97 .catch(err => console.log("err: ", err));98 }99 };100 resetAuth = () => {101 this.getUnlockText();102 this.setState({103 showAuthError: false,104 showAuthSuccess: false,105 authErrorStr: "",106 authSuccessStr: ""107 });108 };109 showAuthError = error => {110 this.setState({111 showAuthError: true,112 authErrorStr: error,113 text: "Try Again"114 });115 };116 showAuthSuccess = str => {117 this.setState({118 showAuthSuccess: true,119 authSuccessStr: str120 });121 };122 getUnlockText = () => {123 const { unlockMethod } = this.props;124 if (unlockMethod === "fingerprint") {125 this.setState({ text: "Touch Sensor Now" });126 } else if (unlockMethod === "faceId") {127 this.setState({ text: "Look at Sensor Now" });128 }129 };130 getUnlockImage = () => {131 const { showAuthError, showAuthSuccess } = this.state;132 const { unlockMethod } = this.props;133 if (unlockMethod === "fingerprint") {134 if (showAuthError) {135 return Images.fingerPrintRed;136 } else if (showAuthSuccess) {137 return Images.fingerPrintGreen;138 }139 return Images.fingerPrint;140 } else if (unlockMethod === "faceId") {141 if (showAuthError) {142 return Images.faceRed;143 } else if (showAuthSuccess) {144 return Images.faceGreen;145 }146 return Images.face;147 }148 };149 render() {150 const { authenticateUser, pin } = this.props;151 const {152 showCodeError,153 codeMatched,154 isModalVisible,155 unlockText,156 showAuthError,157 authErrorStr,158 text159 } = this.state;160 return (161 <View style={styles.container}>162 <ScrollView>163 <View style={{ marginTop: Constants.statusBarHeight + 42 }}>164 <View>165 <Image source={Images.fullLogo} style={{ alignSelf: "center" }} />166 <Custom_Text167 value="Wallet"168 style={{169 textAlign: "center",170 marginBottom: 24171 }}172 size={48}173 />174 </View>175 <View>176 {showCodeError && (177 <View178 style={{179 position: "absolute",180 top: 40,181 alignSelf: "center"182 }}183 >184 <View185 style={{186 flexDirection: "row",187 justifyContent: "center",188 alignItems: "center"189 }}190 >191 <Custom_Text192 value="PIN is incorrect"193 style={{194 textAlign: "center",195 marginRight: 10196 }}197 color={Colors.errorBackground}198 size={16}199 />200 <Image source={Images.smallErrIcon} />201 </View>202 </View>203 )}204 <View style={{ marginTop: 0 }}>205 <PinView206 disabled={codeMatched}207 onComplete={(val, clear) => {208 const v = val.length > 4 ? val.substring(0, 3) : val;209 if (v === pin) {210 this.setState({211 codeMatched: true,212 showCodeError: false213 });214 setTimeout(() => authenticateUser(), 1000);215 } else {216 this.setState({217 codeMatched: false,218 showCodeError: true219 });220 clear();221 }222 }}223 pinLength={4}224 inputViewStyle={{225 marginHorizontal: 20,226 width: 16,227 height: 16,228 borderRadius: 8,229 borderWidth: 2,230 borderColor: codeMatched ? Colors.freshGreen : Colors.text231 }}232 inputBgOpacity={1}233 inputBgColor={Colors.buttonText}234 inputActiveBgColor={235 codeMatched ? Colors.freshGreen : Colors.text236 }237 buttonBgColor={Colors.pinInputBackground}238 keyboardViewTextStyle={{239 fontFamily: "DMSansBold",240 fontSize: 24,241 color: Colors.text,242 tintColor: Colors.text243 }}244 keyboardViewStyle={{245 marginVertical: 8,246 height: 64,247 width: 64248 }}249 keyboardContainerStyle={{250 marginTop: 48,251 marginBottom: 0252 }}253 keyboardViewItemText={{254 tintColor: Colors.text255 }}256 />257 </View>258 </View>259 </View>260 </ScrollView>261 <Modal262 visible={isModalVisible && !isIos}263 animationType={"none"}264 transparent={true}265 onRequestClose={() => {}}266 >267 <View268 style={{269 flex: 1,270 justifyContent: "center",271 backgroundColor: Colors.modalBackground272 }}273 >274 <View275 style={{276 backgroundColor: Colors.buttonText,277 marginHorizontal: 40,278 borderRadius: 10,279 padding: 20280 }}281 >282 <View>283 <Custom_Text284 value={unlockText}285 style={{286 marginBottom: 30,287 textAlign: "center"288 }}289 color={Colors.text}290 size={20}291 isBold292 />293 </View>294 <View>295 <Image296 source={this.getUnlockImage()}297 style={{298 alignSelf: "center",299 height: 66,300 width: 66,301 marginBottom: 16302 }}303 />304 {showAuthError && (305 <Custom_Text306 value={authErrorStr}307 style={{308 textAlign: "center"309 }}310 color={Colors.text}311 size={12}312 />313 )}314 <TouchableOpacity onPress={() => this.authenticateAsync()}>315 <Custom_Text316 value={text}317 style={{318 textAlign: "center",319 marginTop: 8320 }}321 color={Colors.grayText}322 size={12}323 />324 </TouchableOpacity>325 </View>326 <View style={{ alignItems: "flex-end" }}>327 <TouchableOpacity328 onPress={() => this.setState({ isModalVisible: false })}329 >330 <Custom_Text331 value="Use PIN"332 style={{333 marginTop: 10334 }}335 size={14}336 isBold337 />338 </TouchableOpacity>339 </View>340 </View>341 </View>342 </Modal>343 </View>344 );345 }346}347const styles = StyleSheet.create({348 container: {349 flex: 1,350 backgroundColor: Colors.background351 }352});353const mapStateToProps = ({ pin, unlockMethod, isAuthenticated }) => ({354 pin,355 unlockMethod,356 isAuthenticated357});358const mapDispatchToProps = dispatch => ({359 authenticateUser: () => dispatch(authSuccess())360});...

Full Screen

Full Screen

SettingsScreen.js

Source:SettingsScreen.js Github

copy

Full Screen

1import React, { useEffect, useState } from "react";2import { ScrollView, StyleSheet, View } from "react-native";3import { connect } from "react-redux";4import * as WebBrowser from "expo-web-browser";5import * as LocalAuthentication from "expo-local-authentication";6import { persistStore } from "redux-persist";7import Custom_Text from "../components/shared/Custom_Text";8import Custom_Header from "../components/shared/Custom_Header";9import Custom_HeaderTitle from "../components/shared/Custom_HeaderTitle";10import Custom_HeaderButton from "../components/shared/Custom_HeaderButton";11import Colors from "../constants/Colors";12import Custom_NavButton from "../components/shared/Custom_NavButton";13import Custom_MultiSelectInput from "../components/shared/Custom_MultiSelectInput";14import currencies from "../constants/currencies";15import { updateBaseCurrency, getMarketData, purgeStore } from "../actions";16import config from "../constants/config";17import appConfig from "../app.config";18import ResetDataModal from "../components/shared/ResetDataModal";19import { screenWidth } from "../constants/Layout";20function SettingsScreen({21 navigation,22 unlockMethod,23 baseCurrency,24 updateAccountBaseCurrency,25 getMarketData,26 pin,27 purgeStore,28}) {29 // console.log(persistor);30 const [availableUnlockMethods, setAvailableUnlockMethods] = useState(null);31 const [unlockText, setUnlockText] = useState(null);32 const [showModal, setShowModal] = useState(false);33 const [showPinError, setShowPinError] = useState(false);34 const [code, setCode] = useState("");35 useEffect(() => {36 getAvailableUnlockMethods();37 getMarketData(baseCurrency.value);38 }, [availableUnlockMethods]);39 const handleOpenWithWebBrowser = url => {40 WebBrowser.openBrowserAsync(url);41 };42 const getAvailableUnlockMethods = async () => {43 LocalAuthentication.hasHardwareAsync()44 .then(res => {45 if (res) {46 LocalAuthentication.supportedAuthenticationTypesAsync().then(res => {47 if (res.includes(1) && !res.includes(2)) {48 setUnlockText("Enable Fingerprint ID");49 setAvailableUnlockMethods("fingerprint");50 } else if (res.includes(2) && !res.includes(1)) {51 setUnlockText("Enable Face ID");52 setAvailableUnlockMethods("faceId");53 } else if (res.includes(1) && res.includes(2)) {54 setUnlockText("Choose Unlock Method");55 setAvailableUnlockMethods("both");56 } else {57 setUnlockText(null);58 }59 });60 }61 })62 .catch(err => console.log(err));63 };64 return (65 <View style={styles.container}>66 <Custom_Header67 left={68 <Custom_HeaderButton69 onPress={() => {70 navigation.goBack();71 }}72 type="icon"73 icon="md-arrow-back"74 iconColor={Colors.text}75 />76 }77 center={<Custom_HeaderTitle text="Settings" />}78 right={<View />}79 />80 <ScrollView>81 <View style={{ marginTop: 15, marginHorizontal: 15 }}>82 <Custom_Text83 value="Set Default Fiat Currency"84 style={{ marginLeft: 15, marginBottom: 10 }}85 isBold86 />87 <Custom_MultiSelectInput88 value={baseCurrency}89 options={currencies}90 onValueChange={updateAccountBaseCurrency}91 />92 </View>93 <View style={{ marginTop: 15, marginHorizontal: 15 }}>94 <Custom_Text95 value="Security"96 style={{ marginLeft: 15, marginBottom: 10 }}97 isBold98 />99 <Custom_NavButton100 value="Change PIN"101 handleOnPress={() => {102 navigation.navigate({103 key: "ChangePinScreen",104 routeName: "ChangePinScreen",105 });106 }}107 />108 {availableUnlockMethods && (109 <Custom_NavButton110 value="Enable / Disable Face ID / Fingerprint"111 handleOnPress={() => {112 if (!unlockMethod) {113 navigation.navigate({114 key: "SetupUnlockScreen",115 routeName: "SetupUnlockScreen",116 params: {117 unlockText,118 availableUnlockMethods,119 isChangeScreen: true,120 },121 });122 } else {123 navigation.navigate({124 key: "ChangeUnlockScreen",125 routeName: "ChangeUnlockScreen",126 params: {127 unlockText:128 unlockMethod === "faceId" ? "FaceID" : "Fingerprint",129 availableUnlockMethods,130 isChangeScreen: true,131 },132 });133 }134 }}135 />136 )}137 </View>138 <View style={{ marginTop: 15, marginHorizontal: 15 }}>139 <Custom_Text140 value="Legal"141 style={{ marginLeft: 15, marginBottom: 10 }}142 isBold143 />144 <Custom_NavButton145 value="License Agreement"146 handleOnPress={() => {147 // handleOpenWithWebBrowser(config.termsUrl);148 navigation.navigate({149 key: "LicenseAgreementScreen",150 routeName: "LicenseAgreementScreen",151 });152 }}153 />154 {/* <Custom_NavButton155 value="Privacy Policy"156 handleOnPress={() => {157 handleOpenWithWebBrowser(config.privacyUrl);158 }}159 /> */}160 </View>161 <View style={{ marginTop: 15, marginHorizontal: 15 }}>162 <Custom_Text163 value="Support"164 style={{ marginLeft: 15, marginBottom: 10 }}165 isBold166 />167 <Custom_NavButton168 value="Report an Issue"169 handleOnPress={() => {170 handleOpenWithWebBrowser(config.reportIssueUrl);171 }}172 />173 </View>174 <View style={{ marginTop: 15, marginHorizontal: 15 }}>175 <Custom_Text176 value="Reset"177 style={{ marginLeft: 15, marginBottom: 10 }}178 isBold179 />180 <Custom_NavButton181 value="Reset all data"182 handleOnPress={() => {183 setShowModal(true);184 }}185 />186 </View>187 <View style={{ marginTop: 15, marginHorizontal: 15 }}>188 <Custom_Text189 value={`Version ${appConfig.version}`}190 style={{ marginTop: 20, textAlign: "center" }}191 color={Colors.grayText}192 isBold193 />194 </View>195 <View style={{ height: 40, width: screenWidth }} />196 </ScrollView>197 <ResetDataModal198 modalVisible={showModal}199 onClose={() => {200 setShowModal(false);201 setShowPinError(false);202 setCode("");203 }}204 onChangeCode={setCode}205 code={code}206 showError={showPinError}207 onPress={() => {208 if (pin !== code) {209 setShowPinError(true);210 } else {211 setShowModal(false);212 purgeStore();213 }214 }}215 />216 </View>217 );218}219SettingsScreen.navigationOptions = {220 header: null,221};222const styles = StyleSheet.create({223 container: {224 flex: 1,225 backgroundColor: Colors.background,226 },227 section: {228 marginHorizontal: 20,229 marginTop: 20,230 },231});232const mapStateToProps = store => ({233 store,234 unlockMethod: store.unlockMethod,235 baseCurrency: store.baseCurrency,236 pin: store.pin,237 // persistor: store.persistor,238});239const mapDispatchToProps = dispatch => ({240 getMarketData: baseCurrency => dispatch(getMarketData(baseCurrency)),241 completeAuthSetup: () => dispatch(setupAuthentication()),242 authenticateUser: () => dispatch(authSuccess()),243 purgeStore: () => dispatch(purgeStore()),244 saveUnlockMethod: data => dispatch(updateUnlockMethod(data)),245 updateAccountBaseCurrency: data => dispatch(updateBaseCurrency(data)),246});247export default connect(248 mapStateToProps,249 mapDispatchToProps,...

Full Screen

Full Screen

sticker-unlock.js

Source:sticker-unlock.js Github

copy

Full Screen

1import io from '../../io/index'2import {ROUTE} from '../../config/constants'3Page({4 data: {5 stickers: [],6 hasScanQrcodeBtn: false,7 hasShareBtn: false,8 hasInviter: false,9 },10 onLoad(options) {11 const {sticker_id, inviter} = options12 if (inviter) {13 this.setData({hasInviter: true})14 this.initUnlockSticker(sticker_id)15 this.createStickerUnlockLog(sticker_id, +inviter)16 } else {17 this.initStickers(sticker_id)18 }19 },20 initStickers(sticker_id) {21 Promise.all([io.fetchHasLockSticker(), io.fetchStickerUnlockLog()]).then(res => {22 const stickers = res[0].data.objects23 const unlockLogs = res[1].data.objects24 stickers.forEach(item => {25 item.unlockCount = 026 item.unlock_method = item.unlock_method || []27 item.hasShareBtn = item.unlock_method.includes('share')28 unlockLogs.forEach(log => {29 if (log.sticker_id === item.id) {30 if (log.unlock_method === 'scan_qrcode') {31 item.scanedQrcode = true32 } else {33 item.unlockCount += 134 }35 }36 })37 })38 const lockedStickers = stickers.filter(item => {39 return item.has_lock && !item.scanedQrcode && item.unlockCount < 240 })41 const currentStickerIndex = lockedStickers.findIndex(item => item.id === sticker_id)42 this.getUnlockMethod(lockedStickers, currentStickerIndex)43 this.setData({stickers: lockedStickers}, () => {44 this.setData({currentStickerIndex})45 })46 })47 },48 initUnlockSticker(sticker_id) {49 io.fetchStickerById(sticker_id).then(res => {50 const unlockSticker = res.data.objects[0]51 this.setData({unlockSticker})52 })53 },54 createStickerUnlockLog(sticker_id, inviter) {55 io.fetchStickerUnlockLogCount(sticker_id, inviter).then(count => {56 if (inviter == wx.BaaS.storage.get('uid')) {57 wx.redirectTo({url: '/' + ROUTE.STICKER_CAMERA})58 return59 }60 if (count >= 2) return61 io.createStickerUnlockLog(sticker_id, inviter, 'share')62 })63 },64 getUnlockMethod(stickers, currentStickerIndex) {65 const unlockMethod = stickers[currentStickerIndex].unlock_method || []66 this.setData({67 hasScanQrcodeBtn: unlockMethod.includes('scan_qrcode'),68 hasShareBtn: unlockMethod.includes('share'),69 })70 },71 onSwiperChange(e) {72 const {current} = e.detail73 const {stickers} = this.data74 this.getUnlockMethod(stickers, current)75 this.setData({currentStickerIndex: current})76 },77 scanQrcode() {78 wx.scanCode({79 onlyFromCamera: true,80 scanType: ['qrCode'],81 success: res => {82 console.log(res)83 const path = res.path84 if (path) {85 const data = this.parseQrcodePath(path)86 const {sticker_id, scan_qrcode} = data87 if (sticker_id && scan_qrcode) {88 const inviter = wx.BaaS.storage.get('uid')89 io.createStickerUnlockLog(sticker_id, inviter, 'scan_qrcode')90 .then(res => {91 this.setData({afterScanQrcode: true, hasInviter: true})92 this.initUnlockSticker(sticker_id)93 wx.showToast({title: '解锁成功!'})94 })95 .catch(err => {96 this.setData({afterScanQrcode: true, hasInviter: true})97 this.initUnlockSticker(sticker_id)98 wx.showToast({title: '解锁成功!'})99 })100 }101 } else {102 console.log('err')103 }104 },105 })106 },107 onShareAppMessage() {108 const {stickers, currentStickerIndex} = this.data109 const inviter = wx.BaaS.storage.get('uid')110 const image = stickers[currentStickerIndex].image111 const stickerId = stickers[currentStickerIndex].id112 return {113 title: '日本乐高乐园',114 path: `/${ROUTE.STICKER_UNLOCK}?inviter=${inviter}&sticker_id=${stickerId}`,115 imageUrl: image,116 }117 },118 navToHome() {119 wx.reLaunch({url: '/' + ROUTE.INDEX})120 },121 navBack() {122 wx.navigateBack({delta: 1})123 },124 parseQrcodePath(path) {125 const query = path.split('?')[1]126 const data = {}127 if (query) {128 const queryArr = query.split('&')129 queryArr.forEach(item => {130 const arr = item.split('=')131 if (arr[0] === 'sticker_id') {132 data.sticker_id = arr[1]133 }134 if (arr[0] === 'scan_qrcode') {135 data.scan_qrcode = arr[1]136 }137 })138 }139 return data140 },...

Full Screen

Full Screen

WebAuthn.js

Source:WebAuthn.js Github

copy

Full Screen

...39 userHandle: rfc4648.base64url.stringify(Uint8Array.from(accountid, c => c.charCodeAt(0)))40 }41 }42 const unlockMethod = this.unlockMethod || Tine.Tinebase_AreaLock.unlock43 await unlockMethod(this.areaName, this.mfaDevice.id, JSON.stringify(publicKeyData));44 } catch (e) {45 console.error(e);46 Ext.MessageBox.show({47 icon: Ext.MessageBox.WARNING,48 buttons: Ext.MessageBox.OKCANCEL,49 title: i18n._('Error'),50 msg: i18n._("FIDO2 WebAuthn authentication failed. Try again?"),51 fn: (btn) => {52 if (btn === 'ok') {53 Ext.MessageBox.hide();54 return this.unlock();55 } else {56 throw new Error('USERABORT');57 }...

Full Screen

Full Screen

methods.js

Source:methods.js Github

copy

Full Screen

1const mq_connector = require('./mq_connect')2const NodeRSA = require('node-rsa')3var contract;4var unlock;5// Channel handlers6{7 function DIRECTORY_CREATE_REQUEST(request, RESPONDER) {8 let requestId = request.REQUEST_ID9 let userId = request.USER_ID10 let publickey = request.PUBLIC_KEY11 let dateSent = request.DATE_SEND12 let signature = request.SIGNATURE13 let rsaKey = new NodeRSA(publickey)14 let data = Buffer.from(`${userId}-${dateSent}`)15 let signatureVerified = rsaKey.verify(data, signature, 'buffer', 'base64')16 if (!signatureVerified) {17 console.log(` [!] Requestor failed signature verification`);18 RESPONDER(requestId, { STATUS: "ERROR", ERROR: "SIG_FAIL" })19 return20 }21 console.log(` [*] Creating directory entry for ${userId}`);22 if(resolve(userId).PUBLIC_KEY) {23 RESPONDER(requestId, { STATUS: "ERROR", ERROR: "USER_EXISTS" })24 return25 }26 try {27 createEntry(userId, publickey)28 RESPONDER(requestId, { STATUS: "SUCCESS" })29 }30 catch(e) {31 RESPONDER(requestId, { STATUS: "ERROR", ERROR: e.toString() })32 }33 }34 35 function DIRECTORY_VERIFY_REQUEST(request, RESPONDER) {36 let requestId = request.REQUEST_ID37 let userId = request.USER_ID38 console.log(` [*] Verifying directory entry for ${userId}`);39 try {40 verifyEntry(userId)41 RESPONDER(requestId, { STATUS: "SUCCESS" })42 }43 catch(e) {44 RESPONDER(requestId, { STATUS: "ERROR", ERROR: e.toString() })45 }46 }47 48 function DIRECTORY_GET_REQUEST(request, RESPONDER) {49 let requestId = request.REQUEST_ID50 let userId = request.USER_ID51 52 console.log(` [x] Getting key for ${userId}`);53 54 try55 {56 let result = resolve(userId)57 58 console.log(` [/] Resolved key for ${userId}`);59 RESPONDER(requestId, {60 STATUS: 'SUCCESS',61 ENTRY: result62 });63 }64 catch(e)65 {66 RESPONDER(requestId, {67 STATUS: 'ERROR',68 ERROR: e69 });70 }71 }72}73// Internal methods74{75 function resolve(userId) {76 unlock()77 let response = contract.resolve(userId, { gas: 500000 })78 return {79 USER_ID: response[0],80 PUBLIC_KEY: response[1],81 PUBLIC_KEY_HASH: response[2],82 IS_ENTERPRISE: response[3],83 IS_VERIFIED: response[4]84 }85 }86 87 function verifyEntry(userId) {88 unlock()89 contract.verifyEntry(userId, { gas: 500000 })90 }91 92 function createEntry(userId, publicKey) {93 unlock()94 contract.registerEntry(userId, publicKey, { gas: 1500000 })95 }96}97// Initialization methods98{99 function mq_init (mq_host) {100 mq_connector.connect(101 'DIRECTORY-MANAGER',102 'directory_request',103 'directory_response',104 mq_host, 105 [106 { topic: 'create', handler: DIRECTORY_CREATE_REQUEST },107 { topic: 'verify', handler: DIRECTORY_VERIFY_REQUEST },108 { topic: 'get', handler: DIRECTORY_GET_REQUEST }109 ]110 )111 }112 113 function bc_init (contractInstance, unlockMethod) {114 contract = contractInstance115 unlock = unlockMethod116 }117}118module.exports = {119 mq_init: mq_init,120 bc_init: bc_init...

Full Screen

Full Screen

Generic.js

Source:Generic.js Github

copy

Full Screen

...28 pwDlg.openWindow()29 pwDlg.on('apply', async (password) => {30 try {31 const unlockMethod = this.unlockMethod || Tine.Tinebase_AreaLock.unlock32 resolve(await unlockMethod(me.areaName, me.mfaDevice.id, password))33 } catch (e) {34 reject(e)35 }36 })37 pwDlg.on('cancel', () => {38 reject(new Error('USERABORT'))39 })40 })41 }42}...

Full Screen

Full Screen

enums_6.js

Source:enums_6.js Github

copy

Full Screen

1var searchData=2[3 ['unlockmethod_0',['UNLOCKMETHOD',['../wrapperstructs_8h.html#a4c4a2227e1dbb49489721bc17cc98da3',1,'wrapperstructs.h']]]...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var webdriverio = require('webdriverio');2var opts = {3 desiredCapabilities: {4 }5};6var client = webdriverio.remote(opts);7 .init()8 .unlock()9 .end();10var webdriverio = require('webdriverio');11var opts = {12 desiredCapabilities: {13 }14};15var client = webdriverio.remote(opts);16 .init()17 .swipe(100, 100, 100, 400, 1000)18 .end();19var webdriverio = require('webdriverio');20var opts = {21 desiredCapabilities: {22 }23};24var client = webdriverio.remote(opts);25 .init()26 .tap(100, 100)27 .end();28var webdriverio = require('webdriverio');29var opts = {30 desiredCapabilities: {31 }32};

Full Screen

Using AI Code Generation

copy

Full Screen

1const {remote} = require('webdriverio');2const opts = {3 capabilities: {4 }5};6(async () => {7 const browser = await remote(opts);8 await browser.unlock();9})();

Full Screen

Using AI Code Generation

copy

Full Screen

1const wd = require('wd');2const assert = require('assert');3const serverConfig = {4};5const driver = wd.promiseChainRemote(serverConfig);6const desiredCaps = {7};8driver.init(desiredCaps)9 .then(() => driver.unlock())10 .catch((err) => console.log(err));

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium Android Driver automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful