@onairos/react-native 1.0.3 → 2.0.0

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,240 @@ 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
+ var PackageInfo = _interopRequireWildcard(require("react-native-package-info"));
13
14
  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');
15
+ 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
16
  const Overlay = ({
18
- visible,
19
- onClose,
20
- onAccept,
21
- AppName,
22
- requestData,
23
- biometricType = _reactNative.Platform.OS === 'ios' ? 'FaceID' : 'BiometricID'
17
+ data,
18
+ username,
19
+ modelKey,
20
+ onResolved
24
21
  }) => {
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
22
+ const [selections, setSelections] = (0, _react.useState)({});
23
+ const [details, setDetails] = (0, _react.useState)('');
24
+ const bottomSheetRef = _react.default.useRef(null);
29
25
  (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();
26
+ // Initialize selection state
27
+ const initialSelections = {};
28
+ Object.keys(data).forEach(key => {
29
+ initialSelections[key] = false;
30
+ });
31
+ setSelections(initialSelections);
32
+ getDetails();
33
+ }, []);
34
+ const getDetails = async () => {
35
+ try {
36
+ const response = await _api.onairosApi.post('getAccountInfo', {
37
+ Info: {
38
+ username: username
39
+ }
40
+ });
41
+ setDetails(response.AccountInfo);
42
+ } catch (e) {
43
+ console.error('Error getting account info:', e);
36
44
  }
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';
45
+ };
46
+ const closeOverlay = () => {
47
+ var _bottomSheetRef$curre;
48
+ (_bottomSheetRef$curre = bottomSheetRef.current) === null || _bottomSheetRef$curre === void 0 || _bottomSheetRef$curre.dismiss();
49
+ };
50
+ const confirmSelection = async () => {
51
+ try {
52
+ const packageInfo = await PackageInfo.getPackageInfo();
53
+ const serverPublicKey = await (0, _encryption.getServerPublicKey)();
54
+ const encryptedModelKey = (0, _encryption.encryptModelKey)(serverPublicKey, modelKey);
55
+ const response = await _api.onairosApi.post('getAPIUrlMobile', {
56
+ Info: {
57
+ storage: 'local',
58
+ appId: packageInfo.packageName,
59
+ confirmations: selections,
60
+ developerURL: 'devURL',
61
+ EncryptedUserPin: encryptedModelKey,
62
+ account: username,
63
+ proofMode: false
64
+ }
65
+ });
66
+ if (response.apiUrl && response.token) {
67
+ onResolved(response.apiUrl, response.token, {
68
+ username
69
+ });
70
+ closeOverlay();
71
+ }
72
+ } catch (e) {
73
+ console.error('Error in confirmSelection:', e);
74
+ showErrorModal('Failed to confirm selection. Please try again.');
48
75
  }
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
76
  };
73
- return /*#__PURE__*/_react.default.createElement(_bottomSheet.default, {
77
+ const showErrorModal = errorMessage => {
78
+ _reactNative.Alert.alert('Notice', errorMessage, [{
79
+ text: 'OK'
80
+ }]);
81
+ };
82
+ const selectedCount = Object.values(selections).filter(Boolean).length;
83
+ return /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetModal, {
74
84
  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
- })
85
+ snapPoints: ['80%'],
86
+ backdropComponent: props => /*#__PURE__*/_react.default.createElement(_bottomSheet.BottomSheetBackdrop, _extends({}, props, {
87
+ appearsOnIndex: 0,
88
+ disappearsOnIndex: -1
89
+ }))
89
90
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
90
91
  style: styles.container
91
92
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
92
93
  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, {
94
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
98
95
  style: styles.headerTitle
99
- }, "Data Request"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
100
- onPress: onClose,
96
+ }, "Onairos"), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
97
+ onPress: closeOverlay
98
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
101
99
  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, {
100
+ }, "\xD7")), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
101
+ style: styles.username
102
+ }, username)), /*#__PURE__*/_react.default.createElement(_reactNative.ScrollView, {
107
103
  style: styles.content
104
+ }, Object.entries(data).map(([key, value]) => /*#__PURE__*/_react.default.createElement(_reactNative.View, {
105
+ key: key,
106
+ style: styles.card
107
+ }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
108
+ style: styles.checkboxContainer,
109
+ onPress: () => setSelections(prev => ({
110
+ ...prev,
111
+ [key]: !prev[key]
112
+ }))
108
113
  }, /*#__PURE__*/_react.default.createElement(_reactNative.View, {
109
- style: styles.appInfoContainer
114
+ style: [styles.checkbox, selections[key] && styles.checkboxSelected]
115
+ }), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
116
+ style: styles.cardContent
110
117
  }, /*#__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, {
118
+ style: styles.cardTitle
119
+ }, value.type, " Insight"), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
120
+ style: styles.cardDescription
121
+ }, "Description: ", value.descriptions), value.reward && /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
122
+ style: styles.cardReward
123
+ }, "Reward: ", value.reward)))))), /*#__PURE__*/_react.default.createElement(_reactNative.View, {
123
124
  style: styles.footer
124
125
  }, /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
125
- style: styles.cancelButton,
126
- onPress: onClose
126
+ style: styles.footerButton,
127
+ onPress: closeOverlay
127
128
  }, /*#__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
129
+ style: styles.footerButtonText
130
+ }, "Cancel")), /*#__PURE__*/_react.default.createElement(_reactNative.Text, {
131
+ style: styles.selectedCount
132
+ }, "Selected: ", selectedCount), /*#__PURE__*/_react.default.createElement(_reactNative.TouchableOpacity, {
133
+ style: styles.footerButton,
134
+ onPress: confirmSelection
132
135
  }, /*#__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
- })))));
136
+ style: styles.footerButtonText
137
+ }, "Confirm")))));
140
138
  };
141
139
  exports.Overlay = Overlay;
142
140
  const styles = _reactNative.StyleSheet.create({
143
141
  container: {
144
142
  flex: 1,
145
- backgroundColor: '#fff'
146
- },
147
- backdrop: {
148
- ..._reactNative.StyleSheet.absoluteFillObject,
149
- backgroundColor: '#000'
143
+ backgroundColor: _constants.COLORS.white,
144
+ borderTopLeftRadius: 10,
145
+ borderTopRightRadius: 10
150
146
  },
151
147
  header: {
152
148
  flexDirection: 'row',
153
149
  alignItems: 'center',
150
+ justifyContent: 'space-between',
154
151
  padding: 16,
155
- backgroundColor: _constants.COLORS.headerBg,
156
- borderTopLeftRadius: 16,
157
- borderTopRightRadius: 16
152
+ backgroundColor: _constants.COLORS.primary,
153
+ borderTopLeftRadius: 10,
154
+ borderTopRightRadius: 10
158
155
  },
159
156
  headerTitle: {
160
- flex: 1,
161
- fontSize: 18,
162
- fontWeight: '600',
163
- marginLeft: 12,
164
- color: '#000'
157
+ fontSize: 24,
158
+ color: _constants.COLORS.white,
159
+ fontWeight: 'bold'
165
160
  },
166
161
  closeButton: {
162
+ fontSize: 24,
163
+ color: _constants.COLORS.white,
167
164
  padding: 8
168
165
  },
166
+ username: {
167
+ fontSize: 18,
168
+ color: _constants.COLORS.primary
169
+ },
169
170
  content: {
170
171
  flex: 1,
171
172
  padding: 16
172
173
  },
173
- appInfoContainer: {
174
- marginBottom: 24
174
+ card: {
175
+ backgroundColor: _constants.COLORS.white,
176
+ borderRadius: 8,
177
+ marginBottom: 12,
178
+ shadowColor: _constants.COLORS.black,
179
+ shadowOffset: {
180
+ width: 0,
181
+ height: 2
182
+ },
183
+ shadowOpacity: 0.1,
184
+ shadowRadius: 4,
185
+ elevation: 3
186
+ },
187
+ checkboxContainer: {
188
+ flexDirection: 'row',
189
+ padding: 16,
190
+ alignItems: 'center'
175
191
  },
176
- appName: {
177
- fontSize: 20,
178
- fontWeight: 'bold',
179
- color: '#000',
180
- marginBottom: 4
192
+ checkbox: {
193
+ width: 24,
194
+ height: 24,
195
+ borderRadius: 4,
196
+ borderWidth: 2,
197
+ borderColor: _constants.COLORS.primary,
198
+ marginRight: 12
181
199
  },
182
- requestText: {
183
- fontSize: 16,
184
- color: '#666'
200
+ checkboxSelected: {
201
+ backgroundColor: _constants.COLORS.primary
185
202
  },
186
- categoryContainer: {
187
- marginBottom: 20
203
+ cardContent: {
204
+ flex: 1
188
205
  },
189
- categoryTitle: {
206
+ cardTitle: {
190
207
  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
208
+ fontWeight: 'bold',
209
+ marginBottom: 4
209
210
  },
210
- itemDescription: {
211
+ cardDescription: {
211
212
  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
213
+ color: _constants.COLORS.gray,
214
+ marginBottom: 4
221
215
  },
222
- securityText: {
223
- flex: 1,
216
+ cardReward: {
224
217
  fontSize: 14,
225
- color: '#666',
226
- marginLeft: 8
218
+ color: _constants.COLORS.success,
219
+ fontWeight: 'bold'
227
220
  },
228
221
  footer: {
229
222
  flexDirection: 'row',
223
+ justifyContent: 'space-between',
224
+ alignItems: 'center',
230
225
  padding: 16,
231
226
  borderTopWidth: 1,
232
- borderTopColor: '#eee'
227
+ borderTopColor: _constants.COLORS.lightGray
233
228
  },
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
229
+ footerButton: {
230
+ paddingVertical: 8,
231
+ paddingHorizontal: 16,
232
+ borderRadius: 8,
233
+ backgroundColor: _constants.COLORS.primary
243
234
  },
244
- cancelButtonText: {
235
+ footerButtonText: {
236
+ color: _constants.COLORS.white,
245
237
  fontSize: 16,
246
- fontWeight: '600',
247
- color: '#666'
238
+ fontWeight: '600'
248
239
  },
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: {
240
+ selectedCount: {
260
241
  fontSize: 16,
261
- fontWeight: '600',
262
- color: '#fff',
263
- marginRight: 8
264
- },
265
- buttonIcon: {
266
- marginLeft: 4
242
+ color: _constants.COLORS.gray
267
243
  }
268
244
  });
269
245
  //# sourceMappingURL=Overlay.js.map