@onairos/react-native 1.0.3 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.onairosApi = void 0;
7
+ var _axios = _interopRequireDefault(require("axios"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ const BASE_URL = 'https://api2.onairos.uk';
10
+ class OnairosApi {
11
+ constructor(baseUrl = BASE_URL) {
12
+ this.baseUrl = baseUrl;
13
+ }
14
+ async get(endpoint) {
15
+ try {
16
+ const response = await _axios.default.get(`${this.baseUrl}/${endpoint}`);
17
+ return response.data;
18
+ } catch (error) {
19
+ console.error('API GET Error:', error);
20
+ throw error;
21
+ }
22
+ }
23
+ async post(endpoint, data) {
24
+ try {
25
+ const response = await _axios.default.post(`${this.baseUrl}/${endpoint}`, data);
26
+ return response.data;
27
+ } catch (error) {
28
+ console.error('API POST Error:', error);
29
+ throw error;
30
+ }
31
+ }
32
+ }
33
+ const onairosApi = exports.onairosApi = new OnairosApi();
34
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_axios","_interopRequireDefault","require","e","__esModule","default","BASE_URL","OnairosApi","constructor","baseUrl","get","endpoint","response","axios","data","error","console","post","onairosApi","exports"],"sourceRoot":"..\\..\\..\\src","sources":["api/index.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA0B,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAE1B,MAAMG,QAAQ,GAAG,yBAAyB;AAE1C,MAAMC,UAAU,CAAC;EAGfC,WAAWA,CAACC,OAAe,GAAGH,QAAQ,EAAE;IACtC,IAAI,CAACG,OAAO,GAAGA,OAAO;EACxB;EAEA,MAAMC,GAAGA,CAACC,QAAgB,EAAE;IAC1B,IAAI;MACF,MAAMC,QAAQ,GAAG,MAAMC,cAAK,CAACH,GAAG,CAAC,GAAG,IAAI,CAACD,OAAO,IAAIE,QAAQ,EAAE,CAAC;MAC/D,OAAOC,QAAQ,CAACE,IAAI;IACtB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,gBAAgB,EAAEA,KAAK,CAAC;MACtC,MAAMA,KAAK;IACb;EACF;EAEA,MAAME,IAAIA,CAACN,QAAgB,EAAEG,IAAS,EAAE;IACtC,IAAI;MACF,MAAMF,QAAQ,GAAG,MAAMC,cAAK,CAACI,IAAI,CAAC,GAAG,IAAI,CAACR,OAAO,IAAIE,QAAQ,EAAE,EAAEG,IAAI,CAAC;MACtE,OAAOF,QAAQ,CAACE,IAAI;IACtB,CAAC,CAAC,OAAOC,KAAK,EAAE;MACdC,OAAO,CAACD,KAAK,CAAC,iBAAiB,EAAEA,KAAK,CAAC;MACvC,MAAMA,KAAK;IACb;EACF;AACF;AAEO,MAAMG,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAIX,UAAU,CAAC,CAAC","ignoreList":[]}
@@ -7,55 +7,78 @@ exports.OnairosButton = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _UniversalOnboarding = require("./UniversalOnboarding");
10
- var _constants = require("../constants");
11
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
12
11
  const OnairosButton = ({
13
- title,
14
- onPress,
15
- style,
16
- buttonType = 'default',
17
- buttonForm = 'signup',
12
+ returnLink,
13
+ prefillUrl,
18
14
  AppName,
15
+ buttonType = 'normal',
19
16
  requestData,
20
- returnLink,
21
- onComplete,
22
- embedd = false,
17
+ buttonWidth = 180,
18
+ buttonHeight,
19
+ hasStroke = false,
20
+ enabled = true,
21
+ buttonForm = 'default',
22
+ onRejection,
23
+ onResolved,
24
+ preCheck,
25
+ color,
26
+ swerv = false,
23
27
  debug = false,
24
- test = false
28
+ preferredPlatform,
29
+ testMode = false
25
30
  }) => {
26
31
  const [showOnboarding, setShowOnboarding] = (0, _react.useState)(false);
27
- const handlePress = () => {
32
+ const handlePress = async () => {
33
+ if (!enabled) return;
34
+ if (preCheck) {
35
+ const shouldProceed = await preCheck();
36
+ if (!shouldProceed) {
37
+ onRejection === null || onRejection === void 0 || onRejection();
38
+ return;
39
+ }
40
+ }
28
41
  if (buttonForm === 'signup') {
29
42
  setShowOnboarding(true);
30
43
  } else {
31
- onPress();
44
+ // Handle login flow
45
+ // TODO: Implement login flow according to account.md
32
46
  }
33
47
  };
34
48
  const handleOnboardingComplete = (apiUrl, token, data) => {
35
49
  setShowOnboarding(false);
36
- onComplete(apiUrl, token, data);
50
+ onResolved === null || onResolved === void 0 || onResolved(apiUrl, token, data);
37
51
  };
52
+ const buttonStyle = [styles.button, buttonType === 'pill' && styles.pillButton, hasStroke && styles.strokedButton, {
53
+ width: buttonWidth
54
+ }, buttonHeight && {
55
+ height: buttonHeight
56
+ }, color && {
57
+ backgroundColor: color
58
+ }, swerv && styles.swervButton];
59
+ const textStyle = [styles.buttonText, hasStroke && styles.strokedButtonText, color && styles.customColorText];
38
60
  return /*#__PURE__*/_react.default.createElement(_reactNative.View, null, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
39
- style: [styles.button, buttonType === 'pill' && styles.pillButton, style],
40
- onPress: handlePress
61
+ style: buttonStyle,
62
+ onPress: handlePress,
63
+ disabled: !enabled
41
64
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
42
- style: styles.buttonText
43
- }, title)), /*#__PURE__*/_react.default.createElement(_UniversalOnboarding.UniversalOnboarding, {
65
+ style: textStyle
66
+ }, AppName)), /*#__PURE__*/_react.default.createElement(_UniversalOnboarding.UniversalOnboarding, {
44
67
  visible: showOnboarding,
45
68
  onClose: () => setShowOnboarding(false),
46
69
  AppName: AppName,
47
70
  requestData: requestData,
48
71
  returnLink: returnLink,
49
72
  onComplete: handleOnboardingComplete,
50
- embedd: embedd,
73
+ preferredPlatform: preferredPlatform,
51
74
  debug: debug,
52
- test: test
75
+ test: testMode
53
76
  }));
54
77
  };
55
78
  exports.OnairosButton = OnairosButton;
56
79
  const styles = _reactNative.StyleSheet.create({
57
80
  button: {
58
- backgroundColor: _constants.COLORS.primary,
81
+ backgroundColor: '#000',
59
82
  paddingVertical: 12,
60
83
  paddingHorizontal: 24,
61
84
  borderRadius: 8,
@@ -65,10 +88,26 @@ const styles = _reactNative.StyleSheet.create({
65
88
  pillButton: {
66
89
  borderRadius: 20
67
90
  },
91
+ strokedButton: {
92
+ backgroundColor: 'transparent',
93
+ borderWidth: 1,
94
+ borderColor: '#000'
95
+ },
96
+ swervButton: {
97
+ transform: [{
98
+ rotate: '-2deg'
99
+ }]
100
+ },
68
101
  buttonText: {
69
102
  color: '#fff',
70
103
  fontSize: 16,
71
104
  fontWeight: '600'
105
+ },
106
+ strokedButtonText: {
107
+ color: '#000'
108
+ },
109
+ customColorText: {
110
+ color: '#fff'
72
111
  }
73
112
  });
74
113
  //# sourceMappingURL=OnairosButton.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_UniversalOnboarding","_constants","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","OnairosButton","title","onPress","style","buttonType","buttonForm","AppName","requestData","returnLink","onComplete","embedd","debug","test","showOnboarding","setShowOnboarding","useState","handlePress","handleOnboardingComplete","apiUrl","token","data","createElement","View","TouchableOpacity","styles","button","pillButton","Text","buttonText","UniversalOnboarding","visible","onClose","exports","StyleSheet","create","backgroundColor","COLORS","primary","paddingVertical","paddingHorizontal","borderRadius","alignItems","justifyContent","color","fontSize","fontWeight"],"sourceRoot":"..\\..\\..\\src","sources":["components/OnairosButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAAsC,SAAAD,wBAAAK,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAP,uBAAA,YAAAA,CAAAK,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAA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EAAEqB,MAAM,CAACI;EAAW,GAAE3B,KAAY,CAC7B,CAAC,eAEnB1B,MAAA,CAAAgB,OAAA,CAAA8B,aAAA,CAAC1C,oBAAA,CAAAkD,mBAAmB;IAClBC,OAAO,EAAEjB,cAAe;IACxBkB,OAAO,EAAEA,CAAA,KAAMjB,iBAAiB,CAAC,KAAK,CAAE;IACxCR,OAAO,EAAEA,OAAQ;IACjBC,WAAW,EAAEA,WAAY;IACzBC,UAAU,EAAEA,UAAW;IACvBC,UAAU,EAAEQ,wBAAyB;IACrCP,MAAM,EAAEA,MAAO;IACfC,KAAK,EAAEA,KAAM;IACbC,IAAI,EAAEA;EAAK,CACZ,CACG,CAAC;AAEX,CAAC;AAACoB,OAAA,CAAAhC,aAAA,GAAAA,aAAA;AAEF,MAAMwB,MAAM,GAAGS,uBAAU,CAACC,MAAM,CAAC;EAC/BT,MAAM,EAAE;IACNU,eAAe,EAAEC,iBAAM,CAACC,OAAO;IAC/BC,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACDhB,UAAU,EAAE;IACVc,YAAY,EAAE;EAChB,CAAC;EACDZ,UAAU,EAAE;IACVe,KAAK,EAAE,MAAM;IACbC,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd;AACF,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_UniversalOnboarding","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","OnairosButton","returnLink","prefillUrl","AppName","buttonType","requestData","buttonWidth","buttonHeight","hasStroke","enabled","buttonForm","onRejection","onResolved","preCheck","color","swerv","debug","preferredPlatform","testMode","showOnboarding","setShowOnboarding","useState","handlePress","shouldProceed","handleOnboardingComplete","apiUrl","token","data","buttonStyle","styles","button","pillButton","strokedButton","width","height","backgroundColor","swervButton","textStyle","buttonText","strokedButtonText","customColorText","createElement","View","TouchableOpacity","style","onPress","disabled","Text","UniversalOnboarding","visible","onClose","onComplete","test","exports","StyleSheet","create","paddingVertical","paddingHorizontal","borderRadius","alignItems","justifyContent","borderWidth","borderColor","transform","rotate","fontSize","fontWeight"],"sourceRoot":"..\\..\\..\\src","sources":["components/OnairosButton.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,oBAAA,GAAAF,OAAA;AAA4D,SAAAD,wBAAAI,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAN,uBAAA,YAAAA,CAAAI,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,CAAA,EAAAC,CAAA,OAAAM,CAAA,CAAAK,GAAA,IAAAL,CAAA,CAAAM,GAAA,IAAAP,CAAA,CAAAE,CAAA,EAAAP,CAAA,EA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C/BzB,MAAM,EAAE;IACNK,eAAe,EAAE,MAAM;IACvBqB,eAAe,EAAE,EAAE;IACnBC,iBAAiB,EAAE,EAAE;IACrBC,YAAY,EAAE,CAAC;IACfC,UAAU,EAAE,QAAQ;IACpBC,cAAc,EAAE;EAClB,CAAC;EACD7B,UAAU,EAAE;IACV2B,YAAY,EAAE;EAChB,CAAC;EACD1B,aAAa,EAAE;IACbG,eAAe,EAAE,aAAa;IAC9B0B,WAAW,EAAE,CAAC;IACdC,WAAW,EAAE;EACf,CAAC;EACD1B,WAAW,EAAE;IACX2B,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE;IAAQ,CAAC;EACjC,CAAC;EACD1B,UAAU,EAAE;IACVxB,KAAK,EAAE,MAAM;IACbmD,QAAQ,EAAE,EAAE;IACZC,UAAU,EAAE;EACd,CAAC;EACD3B,iBAAiB,EAAE;IACjBzB,KAAK,EAAE;EACT,CAAC;EACD0B,eAAe,EAAE;IACf1B,KAAK,EAAE;EACT;AACF,CAAC,CAAC","ignoreList":[]}
@@ -6,264 +6,247 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.Overlay = void 0;
7
7
  var _react = _interopRequireWildcard(require("react"));
8
8
  var _reactNative = require("react-native");
9
- var _bottomSheet = _interopRequireDefault(require("@gorhom/bottom-sheet"));
10
- var _MaterialIcons = _interopRequireDefault(require("react-native-vector-icons/MaterialIcons"));
9
+ var _bottomSheet = require("@gorhom/bottom-sheet");
11
10
  var _constants = require("../constants");
12
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var _api = require("../api");
12
+ var _encryption = require("../utils/encryption");
13
13
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
14
- const {
15
- height
16
- } = _reactNative.Dimensions.get('window');
14
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
17
15
  const Overlay = ({
18
- visible,
19
- onClose,
20
- onAccept,
21
- AppName,
22
- requestData,
23
- biometricType = _reactNative.Platform.OS === 'ios' ? 'FaceID' : 'BiometricID'
16
+ data,
17
+ username,
18
+ modelKey,
19
+ onResolved
24
20
  }) => {
25
- const bottomSheetRef = (0, _react.useRef)(null);
26
- const snapPoints = (0, _react.useMemo)(() => ['85%'], []);
27
-
28
- // Expand or collapse the bottom sheet based on visibility
21
+ const [selections, setSelections] = (0, _react.useState)({});
22
+ const [details, setDetails] = (0, _react.useState)('');
23
+ const bottomSheetRef = _react.default.useRef(null);
29
24
  (0, _react.useEffect)(() => {
30
- if (visible) {
31
- var _bottomSheetRef$curre;
32
- (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.expand();
33
- } else {
34
- var _bottomSheetRef$curre2;
35
- (_bottomSheetRef$curre2 = bottomSheetRef.current) === null || _bottomSheetRef$curre2 === void 0 || _bottomSheetRef$curre2.close();
25
+ // Initialize selection state
26
+ const initialSelections = {};
27
+ Object.keys(data).forEach(key => {
28
+ initialSelections[key] = false;
29
+ });
30
+ setSelections(initialSelections);
31
+ getDetails();
32
+ }, []);
33
+ const getDetails = async () => {
34
+ try {
35
+ const response = await _api.onairosApi.post('getAccountInfo', {
36
+ Info: {
37
+ username: username
38
+ }
39
+ });
40
+ setDetails(response.AccountInfo);
41
+ } catch (e) {
42
+ console.error('Error getting account info:', e);
36
43
  }
37
- }, [visible]);
38
-
39
- // Get the icon for the biometric type
40
- const getBiometricIcon = (0, _react.useCallback)(() => {
41
- switch (biometricType) {
42
- case 'FaceID':
43
- return 'face';
44
- case 'TouchID':
45
- return 'fingerprint';
46
- default:
47
- return 'security';
44
+ };
45
+ const closeOverlay = () => {
46
+ var _bottomSheetRef$curre;
47
+ (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.dismiss();
48
+ };
49
+ const confirmSelection = async () => {
50
+ try {
51
+ let appId = 'unknown';
52
+ try {
53
+ // Try to get package info, but don't fail if it's not available
54
+ const PackageInfo = require('react-native-package-info');
55
+ const packageInfo = await PackageInfo.getPackageInfo();
56
+ appId = packageInfo.packageName;
57
+ } catch (e) {
58
+ console.warn('Package info not available:', e);
59
+ }
60
+ const serverPublicKey = await (0, _encryption.getServerPublicKey)();
61
+ const encryptedModelKey = (0, _encryption.encryptModelKey)(serverPublicKey, modelKey);
62
+ const response = await _api.onairosApi.post('getAPIUrlMobile', {
63
+ Info: {
64
+ storage: 'local',
65
+ appId: appId,
66
+ confirmations: selections,
67
+ developerURL: 'devURL',
68
+ EncryptedUserPin: encryptedModelKey,
69
+ account: username,
70
+ proofMode: false
71
+ }
72
+ });
73
+ if (response.apiUrl && response.token) {
74
+ onResolved(response.apiUrl, response.token, {
75
+ username
76
+ });
77
+ closeOverlay();
78
+ }
79
+ } catch (e) {
80
+ console.error('Error in confirmSelection:', e);
81
+ showErrorModal('Failed to confirm selection. Please try again.');
48
82
  }
49
- }, [biometricType]);
50
-
51
- // Render the requested data sections
52
- const renderDataCategories = () => {
53
- return Object.entries(requestData).map(([category, items]) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
54
- key: category,
55
- style: styles.categoryContainer
56
- }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
57
- style: styles.categoryTitle
58
- }, category), Object.entries(items).map(([item, description]) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
59
- key: item,
60
- style: styles.itemContainer
61
- }, /*#__PURE__*/_react.default.createElement(_MaterialIcons.default, {
62
- name: "check-circle",
63
- size: 20,
64
- color: _constants.COLORS.primary
65
- }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
66
- style: styles.itemContent
67
- }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
68
- style: styles.itemTitle
69
- }, item), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
70
- style: styles.itemDescription
71
- }, description))))));
72
83
  };
73
- return /*#__PURE__*/_react.default.createElement(_bottomSheet.default, {
84
+ const showErrorModal = errorMessage => {
85
+ _reactNative.Alert.alert('Notice', errorMessage, [{
86
+ text: 'OK'
87
+ }]);
88
+ };
89
+ const selectedCount = Object.values(selections).filter(Boolean).length;
90
+ return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
74
91
  ref: bottomSheetRef,
75
- index: visible ? 0 : -1,
76
- snapPoints: snapPoints,
77
- enablePanDownToClose: true,
78
- onClose: onClose,
79
- backdropComponent: ({
80
- animatedIndex
81
- }) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
82
- style: [styles.backdrop, {
83
- opacity: animatedIndex.interpolate({
84
- inputRange: [0, 1],
85
- outputRange: [0.5, 0]
86
- })
87
- }]
88
- })
92
+ snapPoints: ['80%'],
93
+ backdropComponent: props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
94
+ appearsOnIndex: 0,
95
+ disappearsOnIndex: -1
96
+ }))
89
97
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
90
98
  style: styles.container
91
99
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
92
100
  style: styles.header
93
- }, /*#__PURE__*/_react.default.createElement(_MaterialIcons.default, {
94
- name: "shield",
95
- size: 24,
96
- color: _constants.COLORS.primary
97
- }), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
101
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
98
102
  style: styles.headerTitle
99
- }, "Data Request"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
100
- onPress: onClose,
103
+ }, "Onairos"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
104
+ onPress: closeOverlay
105
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
101
106
  style: styles.closeButton
102
- }, /*#__PURE__*/_react.default.createElement(_MaterialIcons.default, {
103
- name: "close",
104
- size: 24,
105
- color: "#000"
106
- }))), /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
107
+ }, "\xD7")), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
108
+ style: styles.username
109
+ }, username)), /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
107
110
  style: styles.content
111
+ }, Object.entries(data).map(([key, value]) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
112
+ key: key,
113
+ style: styles.card
114
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
115
+ style: styles.checkboxContainer,
116
+ onPress: () => setSelections(prev => ({
117
+ ...prev,
118
+ [key]: !prev[key]
119
+ }))
108
120
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
109
- style: styles.appInfoContainer
121
+ style: [styles.checkbox, selections[key] && styles.checkboxSelected]
122
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
123
+ style: styles.cardContent
110
124
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
111
- style: styles.appName
112
- }, AppName), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
113
- style: styles.requestText
114
- }, "is requesting access to the following data:")), renderDataCategories(), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
115
- style: styles.securityNotice
116
- }, /*#__PURE__*/_react.default.createElement(_MaterialIcons.default, {
117
- name: "security",
118
- size: 20,
119
- color: "#666"
120
- }), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
121
- style: styles.securityText
122
- }, "Your data is securely processed and never shared with third parties."))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
125
+ style: styles.cardTitle
126
+ }, value.type, " Insight"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
127
+ style: styles.cardDescription
128
+ }, "Description: ", value.descriptions), value.reward && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
129
+ style: styles.cardReward
130
+ }, "Reward: ", value.reward)))))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
123
131
  style: styles.footer
124
132
  }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
125
- style: styles.cancelButton,
126
- onPress: onClose
133
+ style: styles.footerButton,
134
+ onPress: closeOverlay
127
135
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
128
- style: styles.cancelButtonText
129
- }, "Deny")), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
130
- style: styles.acceptButton,
131
- onPress: onAccept
136
+ style: styles.footerButtonText
137
+ }, "Cancel")), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
138
+ style: styles.selectedCount
139
+ }, "Selected: ", selectedCount), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
140
+ style: styles.footerButton,
141
+ onPress: confirmSelection
132
142
  }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
133
- style: styles.acceptButtonText
134
- }, "Accept"), /*#__PURE__*/_react.default.createElement(_MaterialIcons.default, {
135
- name: getBiometricIcon(),
136
- size: 20,
137
- color: "#fff",
138
- style: styles.buttonIcon
139
- })))));
143
+ style: styles.footerButtonText
144
+ }, "Confirm")))));
140
145
  };
141
146
  exports.Overlay = Overlay;
142
147
  const styles = _reactNative.StyleSheet.create({
143
148
  container: {
144
149
  flex: 1,
145
- backgroundColor: '#fff'
146
- },
147
- backdrop: {
148
- ..._reactNative.StyleSheet.absoluteFillObject,
149
- backgroundColor: '#000'
150
+ backgroundColor: _constants.COLORS.white,
151
+ borderTopLeftRadius: 10,
152
+ borderTopRightRadius: 10
150
153
  },
151
154
  header: {
152
155
  flexDirection: 'row',
153
156
  alignItems: 'center',
157
+ justifyContent: 'space-between',
154
158
  padding: 16,
155
- backgroundColor: _constants.COLORS.headerBg,
156
- borderTopLeftRadius: 16,
157
- borderTopRightRadius: 16
159
+ backgroundColor: _constants.COLORS.primary,
160
+ borderTopLeftRadius: 10,
161
+ borderTopRightRadius: 10
158
162
  },
159
163
  headerTitle: {
160
- flex: 1,
161
- fontSize: 18,
162
- fontWeight: '600',
163
- marginLeft: 12,
164
- color: '#000'
164
+ fontSize: 24,
165
+ color: _constants.COLORS.white,
166
+ fontWeight: 'bold'
165
167
  },
166
168
  closeButton: {
169
+ fontSize: 24,
170
+ color: _constants.COLORS.white,
167
171
  padding: 8
168
172
  },
173
+ username: {
174
+ fontSize: 18,
175
+ color: _constants.COLORS.primary
176
+ },
169
177
  content: {
170
178
  flex: 1,
171
179
  padding: 16
172
180
  },
173
- appInfoContainer: {
174
- marginBottom: 24
181
+ card: {
182
+ backgroundColor: _constants.COLORS.white,
183
+ borderRadius: 8,
184
+ marginBottom: 12,
185
+ shadowColor: _constants.COLORS.black,
186
+ shadowOffset: {
187
+ width: 0,
188
+ height: 2
189
+ },
190
+ shadowOpacity: 0.1,
191
+ shadowRadius: 4,
192
+ elevation: 3
193
+ },
194
+ checkboxContainer: {
195
+ flexDirection: 'row',
196
+ padding: 16,
197
+ alignItems: 'center'
175
198
  },
176
- appName: {
177
- fontSize: 20,
178
- fontWeight: 'bold',
179
- color: '#000',
180
- marginBottom: 4
199
+ checkbox: {
200
+ width: 24,
201
+ height: 24,
202
+ borderRadius: 4,
203
+ borderWidth: 2,
204
+ borderColor: _constants.COLORS.primary,
205
+ marginRight: 12
181
206
  },
182
- requestText: {
183
- fontSize: 16,
184
- color: '#666'
207
+ checkboxSelected: {
208
+ backgroundColor: _constants.COLORS.primary
185
209
  },
186
- categoryContainer: {
187
- marginBottom: 20
210
+ cardContent: {
211
+ flex: 1
188
212
  },
189
- categoryTitle: {
213
+ cardTitle: {
190
214
  fontSize: 18,
191
- fontWeight: '600',
192
- color: '#000',
193
- marginBottom: 12
194
- },
195
- itemContainer: {
196
- flexDirection: 'row',
197
- marginBottom: 12,
198
- paddingLeft: 8
199
- },
200
- itemContent: {
201
- flex: 1,
202
- marginLeft: 12
203
- },
204
- itemTitle: {
205
- fontSize: 16,
206
- fontWeight: '500',
207
- color: '#000',
208
- marginBottom: 2
215
+ fontWeight: 'bold',
216
+ marginBottom: 4
209
217
  },
210
- itemDescription: {
218
+ cardDescription: {
211
219
  fontSize: 14,
212
- color: '#666'
213
- },
214
- securityNotice: {
215
- flexDirection: 'row',
216
- alignItems: 'flex-start',
217
- backgroundColor: '#f5f5f5',
218
- padding: 12,
219
- borderRadius: 8,
220
- marginBottom: 24
220
+ color: _constants.COLORS.gray,
221
+ marginBottom: 4
221
222
  },
222
- securityText: {
223
- flex: 1,
223
+ cardReward: {
224
224
  fontSize: 14,
225
- color: '#666',
226
- marginLeft: 8
225
+ color: _constants.COLORS.success,
226
+ fontWeight: 'bold'
227
227
  },
228
228
  footer: {
229
229
  flexDirection: 'row',
230
+ justifyContent: 'space-between',
231
+ alignItems: 'center',
230
232
  padding: 16,
231
233
  borderTopWidth: 1,
232
- borderTopColor: '#eee'
234
+ borderTopColor: _constants.COLORS.lightGray
233
235
  },
234
- cancelButton: {
235
- flex: 1,
236
- justifyContent: 'center',
237
- alignItems: 'center',
238
- paddingVertical: 12,
239
- borderWidth: 1,
240
- borderColor: '#ddd',
241
- borderRadius: 25,
242
- marginRight: 8
236
+ footerButton: {
237
+ paddingVertical: 8,
238
+ paddingHorizontal: 16,
239
+ borderRadius: 8,
240
+ backgroundColor: _constants.COLORS.primary
243
241
  },
244
- cancelButtonText: {
242
+ footerButtonText: {
243
+ color: _constants.COLORS.white,
245
244
  fontSize: 16,
246
- fontWeight: '600',
247
- color: '#666'
245
+ fontWeight: '600'
248
246
  },
249
- acceptButton: {
250
- flex: 2,
251
- flexDirection: 'row',
252
- justifyContent: 'center',
253
- alignItems: 'center',
254
- paddingVertical: 12,
255
- backgroundColor: _constants.COLORS.primary,
256
- borderRadius: 25,
257
- marginLeft: 8
258
- },
259
- acceptButtonText: {
247
+ selectedCount: {
260
248
  fontSize: 16,
261
- fontWeight: '600',
262
- color: '#fff',
263
- marginRight: 8
264
- },
265
- buttonIcon: {
266
- marginLeft: 4
249
+ color: _constants.COLORS.gray
267
250
  }
268
251
  });
269
252
  //# sourceMappingURL=Overlay.js.map