mirror of
https://github.com/EthanShoeDev/fressh.git
synced 2026-01-11 14:22:51 +00:00
add calc getting started to main app
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
"@dylankenneally/react-native-ssh-sftp": "^1.5.20",
|
||||
"@expo/vector-icons": "^15.0.2",
|
||||
"@fressh/assets": "workspace:*",
|
||||
"@fressh/react-native-uniffi-russh": "workspace:*",
|
||||
"@react-native-picker/picker": "2.11.1",
|
||||
"@react-native-segmented-control/segmented-control": "2.5.7",
|
||||
"@react-navigation/bottom-tabs": "^7.4.0",
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
secretsManager,
|
||||
} from '../lib/secrets-manager';
|
||||
import { sshConnectionManager } from '../lib/ssh-connection-manager';
|
||||
|
||||
import { result } from '../lib/test-uniffi-russh';
|
||||
const defaultValues: ConnectionDetails = {
|
||||
host: 'test.rebex.net',
|
||||
port: 22,
|
||||
@@ -119,7 +119,9 @@ export default function Index() {
|
||||
>
|
||||
<View style={styles.header}>
|
||||
<Text style={styles.appName}>fressh</Text>
|
||||
<Text style={styles.appTagline}>A fast, friendly SSH client</Text>
|
||||
<Text style={styles.appTagline}>
|
||||
A fast, friendly SSH client {result}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.card}>
|
||||
<Text style={styles.title}>Connect to SSH Server</Text>
|
||||
|
||||
32
apps/mobile/src/lib/test-uniffi-russh.ts
Normal file
32
apps/mobile/src/lib/test-uniffi-russh.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
import {
|
||||
Calculator,
|
||||
type BinaryOperator,
|
||||
SafeAddition,
|
||||
type ComputationResult,
|
||||
} from '@fressh/react-native-uniffi-russh';
|
||||
|
||||
const calculator = new Calculator();
|
||||
|
||||
const addOp = new SafeAddition();
|
||||
|
||||
class SafeMultiply implements BinaryOperator {
|
||||
perform(lhs: bigint, rhs: bigint): bigint {
|
||||
return lhs * rhs;
|
||||
}
|
||||
}
|
||||
|
||||
const multOp = new SafeMultiply();
|
||||
|
||||
// bigints
|
||||
const three = 3n;
|
||||
const seven = 7n;
|
||||
|
||||
// Perform the calculation, and to get an object
|
||||
// representing the computation result.
|
||||
const computation: ComputationResult = calculator
|
||||
.calculate(addOp, three, three)
|
||||
.calculateMore(multOp, seven)
|
||||
.lastResult()!;
|
||||
|
||||
// Unpack the bigint value into a string.
|
||||
export const result = computation.value.toString();
|
||||
Reference in New Issue
Block a user