Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
gruve-p committed Sep 18, 2024
2 parents aefefd8 + 2ae59ac commit 51a3ae9
Show file tree
Hide file tree
Showing 59 changed files with 1,638 additions and 1,338 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/lockfiles_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Lock Files Update

on:
workflow_dispatch:
push:
branches:
- master

jobs:
pod-update:
runs-on: macos-latest
permissions:
contents: write
steps:

- name: Checkout master branch
uses: actions/checkout@v4
with:
ref: master # Ensures we're checking out the master branch
fetch-depth: 0 # Ensures full history to enable branch deletion and recreation

- name: Delete existing branch
run: |
git push origin --delete pod-update-branch || echo "Branch does not exist, continuing..."
git branch -D pod-update-branch || echo "Local branch does not exist, continuing..."
- name: Create new branch from master
run: git checkout -b pod-update-branch # Create a new branch from the master branch

- name: Specify node version
uses: actions/setup-node@v4
with:
node-version: 20

- name: Install node modules
run: npm install

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.1.6
bundler-cache: true

- name: Install and update Ruby Gems
run: |
bundle install
- name: Install CocoaPods Dependencies
run: |
cd ios
pod install
pod update
- name: Check for changes
id: check-changes
run: |
git diff --quiet package-lock.json ios/Podfile.lock || echo "Changes detected"
continue-on-error: true

- name: Stop job if no changes
if: steps.check-changes.outcome == 'success'
run: |
echo "No changes detected in package-lock.json or Podfile.lock. Stopping the job."
exit 0
- name: Commit changes
if: steps.check-changes.outcome != 'success'
run: |
git add package-lock.json ios/Podfile.lock
git commit -m "Update lock files"
# Step 10: Get the list of changed files for PR description
- name: Get changed files for PR description
id: get-changes
if: steps.check-changes.outcome != 'success'
run: |
git diff --name-only HEAD^ HEAD > changed_files.txt
echo "CHANGES=$(cat changed_files.txt)" >> $GITHUB_ENV
# Step 11: Push the changes and create the PR using the LockFiles PAT
- name: Push and create PR
if: steps.check-changes.outcome != 'success'
run: |
git push origin pod-update-branch
gh pr create --title "Lock Files Updates" --body "The following lock files were updated:\n\n${{ env.CHANGES }}" --base master
env:
GITHUB_TOKEN: ${{ secrets.LOCKFILES_WORKFLOW }} # Use the LockFiles PAT for PR creation

cleanup:
runs-on: macos-latest
if: github.event.pull_request.merged == true || github.event.pull_request.state == 'closed'
needs: pod-update
steps:

- name: Delete branch after PR merge/close
run: |
git push origin --delete pod-update-branch
70 changes: 1 addition & 69 deletions BlueComponents.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
/* eslint react/prop-types: "off", react-native/no-inline-styles: "off" */
import Clipboard from '@react-native-clipboard/clipboard';
import React, { forwardRef } from 'react';
import {
ActivityIndicator,
Dimensions,
I18nManager,
InputAccessoryView,
Keyboard,
Platform,
StyleSheet,
TextInput,
TouchableOpacity,
View,
} from 'react-native';
import { ActivityIndicator, Dimensions, I18nManager, Platform, StyleSheet, TextInput, TouchableOpacity, View } from 'react-native';
import { Icon, Text } from '@rneui/themed';

import { useTheme } from './components/themes';
import loc from './loc';

const { height, width } = Dimensions.get('window');
const aspectRatio = height / width;
Expand Down Expand Up @@ -137,60 +123,6 @@ export const BlueSpacing10 = props => {
return <View {...props} style={{ height: 10, opacity: 0 }} />;
};

export const BlueDismissKeyboardInputAccessory = () => {
const { colors } = useTheme();
BlueDismissKeyboardInputAccessory.InputAccessoryViewID = 'BlueDismissKeyboardInputAccessory';

return Platform.OS !== 'ios' ? null : (
<InputAccessoryView nativeID={BlueDismissKeyboardInputAccessory.InputAccessoryViewID}>
<View
style={{
backgroundColor: colors.inputBackgroundColor,
height: 44,
flex: 1,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
}}
>
<BlueButtonLink title={loc.send.input_done} onPress={Keyboard.dismiss} />
</View>
</InputAccessoryView>
);
};

export const BlueDoneAndDismissKeyboardInputAccessory = props => {
const { colors } = useTheme();
BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID = 'BlueDoneAndDismissKeyboardInputAccessory';

const onPasteTapped = async () => {
const clipboard = await Clipboard.getString();
props.onPasteTapped(clipboard);
};

const inputView = (
<View
style={{
backgroundColor: colors.inputBackgroundColor,
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
maxHeight: 44,
}}
>
<BlueButtonLink title={loc.send.input_clear} onPress={props.onClearTapped} />
<BlueButtonLink title={loc.send.input_paste} onPress={onPasteTapped} />
<BlueButtonLink title={loc.send.input_done} onPress={Keyboard.dismiss} />
</View>
);

if (Platform.OS === 'ios') {
return <InputAccessoryView nativeID={BlueDoneAndDismissKeyboardInputAccessory.InputAccessoryViewID}>{inputView}</InputAccessoryView>;
} else {
return inputView;
}
};

export const BlueLoading = props => {
return (
<View style={{ flex: 1, justifyContent: 'center' }} {...props}>
Expand Down
67 changes: 29 additions & 38 deletions blue_modules/fs.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import LocalQRCode from '@remobile/react-native-qrcode-local-image';
import { Alert, Linking, PermissionsAndroid, Platform } from 'react-native';
import { Alert, Linking, Platform } from 'react-native';
import DocumentPicker from 'react-native-document-picker';
import RNFS from 'react-native-fs';
import { launchImageLibrary } from 'react-native-image-picker';
import Share from 'react-native-share';

import { request, PERMISSIONS } from 'react-native-permissions';
import presentAlert from '../components/Alert';
import loc from '../loc';
import { isDesktop } from './environment';
Expand Down Expand Up @@ -39,51 +39,42 @@ const _shareOpen = async (filePath: string, showShareDialog: boolean = false) =>
* Writes a file to fs, and triggers an OS sharing dialog, so user can decide where to put this file (share to cloud
* or perhabs messaging app). Provided filename should be just a file name, NOT a path
*/

export const writeFileAndExport = async function (fileName: string, contents: string, showShareDialog: boolean = true) {
const sanitizedFileName = _sanitizeFileName(fileName);
if (Platform.OS === 'ios') {
const filePath = RNFS.TemporaryDirectoryPath + `/${sanitizedFileName}`;
await RNFS.writeFile(filePath, contents);
await _shareOpen(filePath, showShareDialog);
} else if (Platform.OS === 'android') {
const granted = await PermissionsAndroid.request(PermissionsAndroid.PERMISSIONS.WRITE_EXTERNAL_STORAGE, {
title: loc.send.permission_storage_title,
message: loc.send.permission_storage_message,
buttonNeutral: loc.send.permission_storage_later,
buttonNegative: loc._.cancel,
buttonPositive: loc._.ok,
});

// In Android 13 no WRITE_EXTERNAL_STORAGE permission is needed
// @see https://stackoverflow.com/questions/76311685/permissionandroid-request-always-returns-never-ask-again-without-any-prompt-r
if (granted === PermissionsAndroid.RESULTS.GRANTED || Platform.Version >= 30) {
const filePath = RNFS.DownloadDirectoryPath + `/${sanitizedFileName}`;
try {
await RNFS.writeFile(filePath, contents);
console.log(`file saved to ${filePath}`);
if (showShareDialog) {
await _shareOpen(filePath);
} else {
presentAlert({ message: loc.formatString(loc.send.file_saved_at_path, { fileName: sanitizedFileName }) });
const isAndroidVersion33OrAbove = Platform.Version >= 33;
const permissionType = isAndroidVersion33OrAbove ? PERMISSIONS.ANDROID.READ_MEDIA_IMAGES : PERMISSIONS.ANDROID.READ_EXTERNAL_STORAGE;
request(permissionType).then(async result => {
if (result === 'granted') {
const filePath = RNFS.ExternalDirectoryPath + `/${sanitizedFileName}`;
try {
await RNFS.writeFile(filePath, contents);
if (showShareDialog) {
await _shareOpen(filePath);
} else {
presentAlert({ message: loc.formatString(loc.send.file_saved_at_path, { filePath }) });
}
} catch (e: any) {
presentAlert({ message: e.message });
}
} catch (e: any) {
console.log(e);
}
} else {
console.log('Storage Permission: Denied');
Alert.alert(loc.send.permission_storage_title, loc.send.permission_storage_denied_message, [
{
text: loc.send.open_settings,
onPress: () => {
Linking.openSettings();
} else {
Alert.alert(loc.send.permission_storage_title, loc.send.permission_storage_denied_message, [
{
text: loc.send.open_settings,
onPress: () => {
Linking.openSettings();
},
style: 'default',
},
style: 'default',
},
{ text: loc._.cancel, onPress: () => {}, style: 'cancel' },
]);
}
} else {
presentAlert({ message: 'Not implemented for this platform' });
{ text: loc._.cancel, onPress: () => {}, style: 'cancel' },
]);
}
});
}
};

Expand Down
2 changes: 1 addition & 1 deletion blue_modules/notifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function Notifications(props) {
* - if you are not using remote notification or do not have Firebase installed, use this:
* requestPermissions: Platform.OS === 'ios'
*/
requestPermissions: Platform.OS === 'ios',
requestPermissions: true,
});
}
});
Expand Down
53 changes: 53 additions & 0 deletions components/AddWalletButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useCallback, useMemo } from 'react';
import { StyleSheet, TouchableOpacity, GestureResponderEvent } from 'react-native';
import { Icon } from '@rneui/themed';
import { useTheme } from './themes';
import ToolTipMenu from './TooltipMenu';
import { CommonToolTipActions } from '../typings/CommonToolTipActions';
import loc from '../loc';
import { navigationRef } from '../NavigationService';

type AddWalletButtonProps = {
onPress?: (event: GestureResponderEvent) => void;
};

const styles = StyleSheet.create({
ball: {
width: 30,
height: 30,
borderRadius: 15,
justifyContent: 'center',
alignContent: 'center',
},
});

const AddWalletButton: React.FC<AddWalletButtonProps> = ({ onPress }) => {
const { colors } = useTheme();
const stylesHook = StyleSheet.create({
ball: {
backgroundColor: colors.buttonBackgroundColor,
},
});

const onPressMenuItem = useCallback((action: string) => {
switch (action) {
case CommonToolTipActions.ImportWallet.id:
navigationRef.current?.navigate('AddWalletRoot', { screen: 'ImportWallet' });
break;
default:
break;
}
}, []);

const actions = useMemo(() => [CommonToolTipActions.ImportWallet], []);

return (
<ToolTipMenu accessibilityRole="button" accessibilityLabel={loc.wallets.add_title} onPressMenuItem={onPressMenuItem} actions={actions}>
<TouchableOpacity style={[styles.ball, stylesHook.ball]} onPress={onPress}>
<Icon name="add" size={22} type="ionicons" color={colors.foregroundColor} />
</TouchableOpacity>
</ToolTipMenu>
);
};

export default AddWalletButton;
Loading

0 comments on commit 51a3ae9

Please sign in to comment.