@oxyhq/services 5.3.5 → 5.3.6

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.
@@ -10,7 +10,7 @@ var _OxyContext = require("../context/OxyContext");
10
10
  var _fonts = require("../styles/fonts");
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  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); }
13
- const AccountSwitcherScreen = ({
13
+ const ModernAccountSwitcherScreen = ({
14
14
  onClose,
15
15
  theme,
16
16
  navigate,
@@ -26,11 +26,16 @@ const AccountSwitcherScreen = ({
26
26
  logoutAll,
27
27
  isLoading
28
28
  } = (0, _OxyContext.useOxy)();
29
- const [allDeviceSessions, setAllDeviceSessions] = (0, _react.useState)([]);
30
- const [loadingDeviceSessions, setLoadingDeviceSessions] = (0, _react.useState)(false);
29
+ const [sessionsWithUsers, setSessionsWithUsers] = (0, _react.useState)([]);
31
30
  const [switchingToUserId, setSwitchingToUserId] = (0, _react.useState)(null);
32
31
  const [removingUserId, setRemovingUserId] = (0, _react.useState)(null);
33
- const [showRemoteDevices, setShowRemoteDevices] = (0, _react.useState)(false);
32
+
33
+ // Device session management state
34
+ const [showDeviceManagement, setShowDeviceManagement] = (0, _react.useState)(false);
35
+ const [deviceSessions, setDeviceSessions] = (0, _react.useState)([]);
36
+ const [loadingDeviceSessions, setLoadingDeviceSessions] = (0, _react.useState)(false);
37
+ const [remotingLogoutSessionId, setRemoteLogoutSessionId] = (0, _react.useState)(null);
38
+ const [loggingOutAllDevices, setLoggingOutAllDevices] = (0, _react.useState)(false);
34
39
  const screenWidth = _reactNative.Dimensions.get('window').width;
35
40
  const isDarkTheme = theme === 'dark';
36
41
 
@@ -49,36 +54,38 @@ const AccountSwitcherScreen = ({
49
54
  shadow: isDarkTheme ? 'rgba(0,0,0,0.3)' : 'rgba(0,0,0,0.1)'
50
55
  };
51
56
 
52
- // Load all device sessions for remote management
53
- const loadAllDeviceSessions = async () => {
54
- if (!activeSessionId || !oxyServices) return;
55
- setLoadingDeviceSessions(true);
56
- try {
57
- const allSessions = await oxyServices.getSessionsBySessionId(activeSessionId);
58
- const deviceSessions = allSessions.map(session => ({
59
- sessionId: session.sessionId,
60
- deviceId: session.deviceId,
61
- deviceName: session.deviceName || 'Unknown Device',
62
- isActive: session.isActive,
63
- lastActive: session.lastActive || new Date().toISOString(),
64
- expiresAt: session.expiresAt || new Date(Date.now() + 24 * 60 * 60 * 1000).toISOString(),
65
- isCurrent: session.sessionId === activeSessionId
57
+ // Load user profiles for sessions
58
+ (0, _react.useEffect)(() => {
59
+ const loadUserProfiles = async () => {
60
+ if (!sessions.length || !oxyServices) return;
61
+ const updatedSessions = sessions.map(session => ({
62
+ ...session,
63
+ isLoadingProfile: true
66
64
  }));
67
- setAllDeviceSessions(deviceSessions);
68
- } catch (error) {
69
- console.error('Failed to load device sessions:', error);
70
- _reactNative.Alert.alert('Error', 'Failed to load device sessions');
71
- } finally {
72
- setLoadingDeviceSessions(false);
73
- }
74
- };
65
+ setSessionsWithUsers(updatedSessions);
75
66
 
76
- // Load device sessions when showing remote devices
77
- (0, _react.useEffect)(() => {
78
- if (showRemoteDevices) {
79
- loadAllDeviceSessions();
80
- }
81
- }, [showRemoteDevices, activeSessionId, oxyServices]);
67
+ // Load profiles for each session
68
+ for (let i = 0; i < sessions.length; i++) {
69
+ const session = sessions[i];
70
+ try {
71
+ // Try to get user profile using the session
72
+ const userProfile = await oxyServices.getUserBySession(session.sessionId);
73
+ setSessionsWithUsers(prev => prev.map(s => s.sessionId === session.sessionId ? {
74
+ ...s,
75
+ userProfile,
76
+ isLoadingProfile: false
77
+ } : s));
78
+ } catch (error) {
79
+ console.error(`Failed to load profile for session ${session.sessionId}:`, error);
80
+ setSessionsWithUsers(prev => prev.map(s => s.sessionId === session.sessionId ? {
81
+ ...s,
82
+ isLoadingProfile: false
83
+ } : s));
84
+ }
85
+ }
86
+ };
87
+ loadUserProfiles();
88
+ }, [sessions, oxyServices]);
82
89
  const handleSwitchSession = async sessionId => {
83
90
  if (sessionId === user?.sessionId) return; // Already active session
84
91
 
@@ -97,9 +104,10 @@ const AccountSwitcherScreen = ({
97
104
  }
98
105
  };
99
106
  const handleRemoveSession = async sessionId => {
100
- const sessionToRemove = sessions.find(s => s.sessionId === sessionId);
107
+ const sessionToRemove = sessionsWithUsers.find(s => s.sessionId === sessionId);
101
108
  if (!sessionToRemove) return;
102
- _reactNative.Alert.alert('Remove Account', `Are you sure you want to remove this session from this device? You'll need to sign in again to access this account.`, [{
109
+ const displayName = typeof sessionToRemove.userProfile?.name === 'object' ? sessionToRemove.userProfile.name.full || sessionToRemove.userProfile.name.first || sessionToRemove.userProfile.username : sessionToRemove.userProfile?.name || sessionToRemove.userProfile?.username || 'this account';
110
+ _reactNative.Alert.alert('Remove Account', `Are you sure you want to remove ${displayName} from this device? You'll need to sign in again to access this account.`, [{
103
111
  text: 'Cancel',
104
112
  style: 'cancel'
105
113
  }, {
@@ -144,22 +152,41 @@ const AccountSwitcherScreen = ({
144
152
  cancelable: true
145
153
  });
146
154
  };
155
+
156
+ // Device session management functions
157
+ const loadAllDeviceSessions = async () => {
158
+ if (!oxyServices || !user?.sessionId) return;
159
+ setLoadingDeviceSessions(true);
160
+ try {
161
+ // This would call the API to get all device sessions for the current user
162
+ const allSessions = await oxyServices.getDeviceSessions(user.sessionId);
163
+ setDeviceSessions(allSessions || []);
164
+ } catch (error) {
165
+ console.error('Failed to load device sessions:', error);
166
+ _reactNative.Alert.alert('Error', 'Failed to load device sessions. Please try again.');
167
+ } finally {
168
+ setLoadingDeviceSessions(false);
169
+ }
170
+ };
147
171
  const handleRemoteSessionLogout = async (sessionId, deviceName) => {
148
- _reactNative.Alert.alert('Logout Remote Session', `Are you sure you want to logout from "${deviceName}"?`, [{
172
+ _reactNative.Alert.alert('Remove Device Session', `Are you sure you want to sign out from "${deviceName}"? This will end the session on that device.`, [{
149
173
  text: 'Cancel',
150
174
  style: 'cancel'
151
175
  }, {
152
- text: 'Logout',
176
+ text: 'Sign Out',
153
177
  style: 'destructive',
154
178
  onPress: async () => {
179
+ setRemoteLogoutSessionId(sessionId);
155
180
  try {
156
- await oxyServices.logoutSecureSession(activeSessionId, sessionId);
157
- _reactNative.Alert.alert('Success', 'Remote session logged out successfully!');
158
- // Refresh the device sessions list
181
+ await oxyServices?.logoutSecureSession(user?.sessionId || '', sessionId);
182
+ // Refresh device sessions list
159
183
  await loadAllDeviceSessions();
184
+ _reactNative.Alert.alert('Success', `Signed out from ${deviceName} successfully!`);
160
185
  } catch (error) {
161
186
  console.error('Remote logout failed:', error);
162
- _reactNative.Alert.alert('Logout Failed', 'There was a problem logging out the remote session. Please try again.');
187
+ _reactNative.Alert.alert('Logout Failed', 'There was a problem signing out from the device. Please try again.');
188
+ } finally {
189
+ setRemoteLogoutSessionId(null);
163
190
  }
164
191
  }
165
192
  }], {
@@ -167,64 +194,182 @@ const AccountSwitcherScreen = ({
167
194
  });
168
195
  };
169
196
  const handleLogoutAllDevices = async () => {
170
- _reactNative.Alert.alert('Logout All Devices', 'Are you sure you want to logout from all other devices? This will keep your current session active.', [{
197
+ const otherDevicesCount = deviceSessions.filter(session => !session.isCurrent).length;
198
+ if (otherDevicesCount === 0) {
199
+ _reactNative.Alert.alert('No Other Devices', 'No other device sessions found to sign out from.');
200
+ return;
201
+ }
202
+ _reactNative.Alert.alert('Sign Out All Other Devices', `Are you sure you want to sign out from all ${otherDevicesCount} other device(s)? This will end sessions on all other devices except this one.`, [{
171
203
  text: 'Cancel',
172
204
  style: 'cancel'
173
205
  }, {
174
- text: 'Logout All Others',
206
+ text: 'Sign Out All',
175
207
  style: 'destructive',
176
208
  onPress: async () => {
209
+ setLoggingOutAllDevices(true);
177
210
  try {
178
- await oxyServices.logoutAllDeviceSessions(activeSessionId, undefined, true);
179
- _reactNative.Alert.alert('Success', 'All other device sessions logged out successfully!');
180
- // Refresh the device sessions list
211
+ await oxyServices?.logoutAllDeviceSessions(user?.sessionId || '', undefined, true);
212
+ // Refresh device sessions list
181
213
  await loadAllDeviceSessions();
214
+ _reactNative.Alert.alert('Success', `Signed out from all other devices successfully!`);
182
215
  } catch (error) {
183
216
  console.error('Logout all devices failed:', error);
184
- _reactNative.Alert.alert('Logout Failed', 'There was a problem logging out other devices. Please try again.');
217
+ _reactNative.Alert.alert('Logout Failed', 'There was a problem signing out from other devices. Please try again.');
218
+ } finally {
219
+ setLoggingOutAllDevices(false);
185
220
  }
186
221
  }
187
222
  }], {
188
223
  cancelable: true
189
224
  });
190
225
  };
191
- const renderSessionItem = session => {
192
- const isActive = session.sessionId === activeSessionId;
193
- const isSwitching = switchingToUserId === session.sessionId;
194
- const isRemoving = removingUserId === session.sessionId;
195
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
196
- style: [styles.userItem, {
197
- backgroundColor: isActive ? colors.activeCard : colors.surface,
198
- borderColor: isActive ? colors.accent : colors.border
226
+ const renderDeviceSessionItem = deviceSession => {
227
+ const isLoggingOut = remotingLogoutSessionId === deviceSession.sessionId;
228
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
229
+ style: [styles.sessionCard, {
230
+ backgroundColor: deviceSession.isCurrent ? colors.activeCard : colors.card,
231
+ borderColor: deviceSession.isCurrent ? colors.accent : colors.border,
232
+ borderWidth: deviceSession.isCurrent ? 2 : 1
199
233
  }],
200
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
201
- style: styles.userInfo,
202
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
203
- style: [styles.username, {
204
- color: colors.text
205
- }],
206
- children: isActive ? user?.username || 'Current Account' : 'Account Session'
207
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
208
- style: [styles.email, {
209
- color: isDarkTheme ? '#BBBBBB' : '#666666'
210
- }],
211
- children: ["Last active: ", new Date(session.lastActive).toLocaleDateString()]
212
- }), isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
213
- style: [styles.activeBadge, {
214
- backgroundColor: colors.success
234
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
235
+ style: styles.sessionHeader,
236
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
237
+ style: styles.userInfo,
238
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
239
+ style: [styles.displayName, {
240
+ color: colors.text
241
+ }],
242
+ numberOfLines: 1,
243
+ children: [deviceSession.deviceName, deviceSession.isCurrent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
244
+ style: [styles.username, {
245
+ color: colors.accent
246
+ }],
247
+ children: ' (This Device)'
248
+ })]
249
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
250
+ style: [styles.username, {
251
+ color: colors.secondaryText
252
+ }],
253
+ numberOfLines: 1,
254
+ children: ["ID: ...", deviceSession.deviceId.slice(-8)]
255
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
256
+ style: [styles.lastActive, {
257
+ color: colors.secondaryText
258
+ }],
259
+ numberOfLines: 1,
260
+ children: ["Last active: ", new Date(deviceSession.lastActive).toLocaleDateString()]
261
+ })]
262
+ }), !deviceSession.isCurrent && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
263
+ style: [styles.removeButton, {
264
+ borderColor: colors.destructive,
265
+ backgroundColor: colors.background
215
266
  }],
216
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
217
- style: styles.activeBadgeText,
218
- children: "Active"
267
+ onPress: () => handleRemoteSessionLogout(deviceSession.sessionId, deviceSession.deviceName),
268
+ disabled: isLoggingOut,
269
+ children: isLoggingOut ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
270
+ color: colors.destructive,
271
+ size: "small"
272
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
273
+ style: [styles.removeButtonText, {
274
+ color: colors.destructive
275
+ }],
276
+ children: "Sign Out"
219
277
  })
220
278
  })]
279
+ })
280
+ }, deviceSession.sessionId);
281
+ };
282
+
283
+ // Load device sessions when device management is shown
284
+ (0, _react.useEffect)(() => {
285
+ if (showDeviceManagement && deviceSessions.length === 0) {
286
+ loadAllDeviceSessions();
287
+ }
288
+ }, [showDeviceManagement]);
289
+ const renderSessionItem = sessionWithUser => {
290
+ const isActive = sessionWithUser.sessionId === activeSessionId;
291
+ const isSwitching = switchingToUserId === sessionWithUser.sessionId;
292
+ const isRemoving = removingUserId === sessionWithUser.sessionId;
293
+ const {
294
+ userProfile,
295
+ isLoadingProfile
296
+ } = sessionWithUser;
297
+ const displayName = typeof userProfile?.name === 'object' ? userProfile.name.full || userProfile.name.first || userProfile.username : userProfile?.name || userProfile?.username || 'Unknown User';
298
+ const username = userProfile?.username || 'unknown';
299
+ const avatarUrl = userProfile?.avatar?.url;
300
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
301
+ style: [styles.sessionCard, {
302
+ backgroundColor: isActive ? colors.activeCard : colors.card,
303
+ borderColor: isActive ? colors.accent : colors.border,
304
+ borderWidth: isActive ? 2 : 1,
305
+ shadowColor: colors.shadow
306
+ }],
307
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
308
+ style: styles.sessionHeader,
309
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
310
+ style: styles.avatarContainer,
311
+ children: [isLoadingProfile ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
312
+ style: [styles.avatarPlaceholder, {
313
+ backgroundColor: colors.surface
314
+ }],
315
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
316
+ size: "small",
317
+ color: colors.accent
318
+ })
319
+ }) : avatarUrl ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
320
+ source: {
321
+ uri: avatarUrl
322
+ },
323
+ style: styles.avatar
324
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
325
+ style: [styles.avatarPlaceholder, {
326
+ backgroundColor: colors.surface
327
+ }],
328
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
329
+ style: [styles.avatarText, {
330
+ color: colors.accent
331
+ }],
332
+ children: displayName.charAt(0).toUpperCase()
333
+ })
334
+ }), isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
335
+ style: [styles.activeBadge, {
336
+ backgroundColor: colors.success
337
+ }],
338
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
339
+ style: styles.activeBadgeText,
340
+ children: "\u2713"
341
+ })
342
+ })]
343
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
344
+ style: styles.userInfo,
345
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
346
+ style: [styles.displayName, {
347
+ color: colors.text
348
+ }],
349
+ numberOfLines: 1,
350
+ children: displayName
351
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
352
+ style: [styles.username, {
353
+ color: colors.secondaryText
354
+ }],
355
+ numberOfLines: 1,
356
+ children: ["@", username]
357
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
358
+ style: [styles.lastActive, {
359
+ color: colors.secondaryText
360
+ }],
361
+ numberOfLines: 1,
362
+ children: ["Last active: ", new Date(sessionWithUser.lastActive).toLocaleDateString()]
363
+ })]
364
+ })]
221
365
  }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
222
- style: styles.userActions,
366
+ style: styles.sessionActions,
223
367
  children: [!isActive && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
224
368
  style: [styles.switchButton, {
225
- borderColor: colors.accent
369
+ borderColor: colors.accent,
370
+ backgroundColor: colors.background
226
371
  }],
227
- onPress: () => handleSwitchSession(session.sessionId),
372
+ onPress: () => handleSwitchSession(sessionWithUser.sessionId),
228
373
  disabled: isSwitching || isRemoving,
229
374
  children: isSwitching ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
230
375
  color: colors.accent,
@@ -237,10 +382,11 @@ const AccountSwitcherScreen = ({
237
382
  })
238
383
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
239
384
  style: [styles.removeButton, {
240
- borderColor: colors.destructive
385
+ borderColor: colors.destructive,
386
+ backgroundColor: colors.background
241
387
  }],
242
- onPress: () => handleRemoveSession(session.sessionId),
243
- disabled: isSwitching || isRemoving || sessions.length === 1,
388
+ onPress: () => handleRemoveSession(sessionWithUser.sessionId),
389
+ disabled: isSwitching || isRemoving,
244
390
  children: isRemoving ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
245
391
  color: colors.destructive,
246
392
  size: "small"
@@ -252,57 +398,7 @@ const AccountSwitcherScreen = ({
252
398
  })
253
399
  })]
254
400
  })]
255
- }, session.sessionId);
256
- };
257
- const renderDeviceSessionItem = deviceSession => {
258
- const isCurrentSession = deviceSession.isCurrent;
259
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
260
- style: [styles.userItem, {
261
- backgroundColor: isCurrentSession ? colors.activeCard : colors.surface,
262
- borderColor: isCurrentSession ? colors.accent : colors.border
263
- }],
264
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
265
- style: styles.userInfo,
266
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
267
- style: [styles.username, {
268
- color: colors.text
269
- }],
270
- children: [deviceSession.deviceName, isCurrentSession && ' (This Device)']
271
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
272
- style: [styles.email, {
273
- color: isDarkTheme ? '#BBBBBB' : '#666666'
274
- }],
275
- children: ["Last active: ", new Date(deviceSession.lastActive).toLocaleDateString()]
276
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
277
- style: [styles.email, {
278
- color: isDarkTheme ? '#BBBBBB' : '#666666'
279
- }],
280
- children: ["Device ID: ", deviceSession.deviceId.substring(0, 8), "..."]
281
- }), isCurrentSession && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
282
- style: [styles.activeBadge, {
283
- backgroundColor: colors.success
284
- }],
285
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
286
- style: styles.activeBadgeText,
287
- children: "Current"
288
- })
289
- })]
290
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
291
- style: styles.userActions,
292
- children: !isCurrentSession && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
293
- style: [styles.removeButton, {
294
- borderColor: colors.destructive
295
- }],
296
- onPress: () => handleRemoteSessionLogout(deviceSession.sessionId, deviceSession.deviceName),
297
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
298
- style: [styles.removeButtonText, {
299
- color: colors.destructive
300
- }],
301
- children: "Logout"
302
- })
303
- })
304
- })]
305
- }, deviceSession.sessionId);
401
+ }, sessionWithUser.sessionId);
306
402
  };
307
403
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
308
404
  style: [styles.container, {
@@ -323,115 +419,159 @@ const AccountSwitcherScreen = ({
323
419
  style: [styles.title, {
324
420
  color: colors.text
325
421
  }],
326
- children: "Account Switcher"
422
+ children: "Accounts"
327
423
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
328
- style: styles.placeholder
424
+ style: styles.headerSpacer
329
425
  })]
330
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.ScrollView, {
331
- style: styles.scrollView,
332
- contentContainerStyle: styles.scrollContainer,
333
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
334
- style: styles.description,
335
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
336
- style: [styles.descriptionText, {
337
- color: isDarkTheme ? '#BBBBBB' : '#666666'
426
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ScrollView, {
427
+ style: styles.content,
428
+ showsVerticalScrollIndicator: false,
429
+ contentContainerStyle: styles.scrollContent,
430
+ children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
431
+ style: styles.loadingContainer,
432
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
433
+ size: "large",
434
+ color: colors.accent
435
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
436
+ style: [styles.loadingText, {
437
+ color: colors.secondaryText
338
438
  }],
339
- children: "Manage multiple accounts on this device. Switch between accounts or remove them from this device."
340
- })
341
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
342
- style: styles.usersContainer,
439
+ children: "Loading accounts..."
440
+ })]
441
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
343
442
  children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
344
443
  style: [styles.sectionTitle, {
345
444
  color: colors.text
346
445
  }],
347
- children: ["Local Sessions (", sessions.length, ")"]
348
- }), sessions.map(renderSessionItem)]
349
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
350
- style: styles.usersContainer,
351
- children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
352
- style: styles.sectionHeader,
353
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
354
- style: [styles.sectionTitle, {
355
- color: colors.text
446
+ children: ["Saved Accounts (", sessionsWithUsers.length, ")"]
447
+ }), sessionsWithUsers.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
448
+ style: styles.emptyState,
449
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
450
+ style: [styles.emptyText, {
451
+ color: colors.secondaryText
356
452
  }],
357
- children: "All Devices & Sessions"
358
- }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
359
- style: [styles.toggleButton, {
360
- borderColor: colors.accent
453
+ children: "No saved accounts found"
454
+ })
455
+ }) : sessionsWithUsers.map(renderSessionItem), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
456
+ style: styles.actionsSection,
457
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
458
+ style: [styles.actionButton, {
459
+ borderColor: colors.border,
460
+ backgroundColor: colors.card
361
461
  }],
362
- onPress: () => setShowRemoteDevices(!showRemoteDevices),
462
+ onPress: () => navigate?.('SignIn'),
363
463
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
364
- style: [styles.toggleButtonText, {
365
- color: colors.accent
464
+ style: [styles.actionButtonText, {
465
+ color: colors.text
466
+ }],
467
+ children: "+ Add Another Account"
468
+ })
469
+ }), sessionsWithUsers.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
470
+ style: [styles.actionButton, styles.dangerButton, {
471
+ borderColor: colors.destructive,
472
+ backgroundColor: colors.background
473
+ }],
474
+ onPress: handleLogoutAll,
475
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
476
+ style: [styles.dangerButtonText, {
477
+ color: colors.destructive
366
478
  }],
367
- children: showRemoteDevices ? 'Hide' : 'Show'
479
+ children: "Sign Out All Accounts"
368
480
  })
369
481
  })]
370
- }), showRemoteDevices && /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
371
- children: loadingDeviceSessions ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
482
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
483
+ style: styles.actionsSection,
484
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
485
+ style: [styles.actionButton, {
486
+ borderColor: colors.border,
487
+ backgroundColor: colors.card
488
+ }],
489
+ onPress: () => setShowDeviceManagement(!showDeviceManagement),
490
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
491
+ style: [styles.actionButtonText, {
492
+ color: colors.text
493
+ }],
494
+ children: showDeviceManagement ? '− Hide Device Management' : '+ Manage Device Sessions'
495
+ })
496
+ })
497
+ }), showDeviceManagement && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
498
+ style: [styles.deviceManagementSection, {
499
+ backgroundColor: colors.card,
500
+ borderColor: colors.border
501
+ }],
502
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
503
+ style: [styles.sectionTitle, {
504
+ color: colors.text
505
+ }],
506
+ children: "Device Sessions"
507
+ }), loadingDeviceSessions ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
372
508
  style: styles.loadingContainer,
373
509
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
374
- color: colors.accent,
375
- size: "small"
510
+ size: "large",
511
+ color: colors.accent
376
512
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
377
513
  style: [styles.loadingText, {
378
514
  color: colors.secondaryText
379
515
  }],
380
516
  children: "Loading device sessions..."
381
517
  })]
382
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
383
- children: allDeviceSessions.length > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
384
- children: [allDeviceSessions.map(renderDeviceSessionItem), allDeviceSessions.filter(s => !s.isCurrent).length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
385
- style: [styles.actionButton, {
386
- borderColor: colors.destructive,
387
- marginTop: 12
388
- }],
389
- onPress: handleLogoutAllDevices,
390
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
391
- style: [styles.actionButtonText, {
392
- color: colors.destructive
393
- }],
394
- children: "Logout All Other Devices"
395
- })
396
- })]
397
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
518
+ }) : deviceSessions.length === 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
519
+ style: styles.emptyState,
520
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
398
521
  style: [styles.emptyText, {
399
522
  color: colors.secondaryText
400
523
  }],
401
- children: "No other device sessions found"
524
+ children: "No device sessions found"
402
525
  })
403
- })
404
- })]
405
- }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
406
- style: styles.actionsContainer,
407
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
408
- style: [styles.actionButton, {
409
- borderColor: colors.border
410
- }],
411
- onPress: () => navigate('SignIn'),
412
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
413
- style: [styles.actionButtonText, {
414
- color: colors.text
526
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
527
+ children: [deviceSessions.map(renderDeviceSessionItem), deviceSessions.filter(session => !session.isCurrent).length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
528
+ style: [styles.actionButton, styles.dangerButton, {
529
+ borderColor: colors.destructive,
530
+ backgroundColor: colors.background,
531
+ marginTop: 20
532
+ }],
533
+ onPress: handleLogoutAllDevices,
534
+ disabled: loggingOutAllDevices,
535
+ children: loggingOutAllDevices ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
536
+ color: colors.destructive,
537
+ size: "small"
538
+ }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
539
+ style: [styles.dangerButtonText, {
540
+ color: colors.destructive
541
+ }],
542
+ children: "Sign Out All Other Devices"
543
+ })
544
+ })]
545
+ })]
546
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
547
+ style: styles.actionsSection,
548
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
549
+ style: [styles.actionButton, {
550
+ borderColor: colors.border,
551
+ backgroundColor: colors.card
415
552
  }],
416
- children: "Add Another Account"
417
- })
418
- }), sessions.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
419
- style: [styles.dangerButton, {
420
- backgroundColor: isDarkTheme ? '#300000' : '#FFEBEE'
421
- }],
422
- onPress: handleLogoutAll,
423
- disabled: isLoading,
424
- children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
425
- color: colors.destructive,
426
- size: "small"
427
- }) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
428
- style: [styles.dangerButtonText, {
429
- color: colors.destructive
553
+ onPress: () => navigate?.('SignIn'),
554
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
555
+ style: [styles.actionButtonText, {
556
+ color: colors.text
557
+ }],
558
+ children: "+ Add Another Account"
559
+ })
560
+ }), sessionsWithUsers.length > 0 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
561
+ style: [styles.actionButton, styles.dangerButton, {
562
+ borderColor: colors.destructive,
563
+ backgroundColor: colors.background
430
564
  }],
431
- children: "Sign Out All Sessions"
432
- })
565
+ onPress: handleLogoutAll,
566
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
567
+ style: [styles.dangerButtonText, {
568
+ color: colors.destructive
569
+ }],
570
+ children: "Sign Out All Accounts"
571
+ })
572
+ })]
433
573
  })]
434
- })]
574
+ })
435
575
  })]
436
576
  });
437
577
  };
@@ -444,168 +584,187 @@ const styles = _reactNative.StyleSheet.create({
444
584
  alignItems: 'center',
445
585
  justifyContent: 'space-between',
446
586
  paddingHorizontal: 20,
447
- paddingTop: _reactNative.Platform.OS === 'ios' ? 50 : 20,
448
- paddingBottom: 20,
449
- borderBottomWidth: 1,
450
- borderBottomColor: 'rgba(0, 0, 0, 0.1)'
587
+ paddingTop: 20,
588
+ paddingBottom: 10
451
589
  },
452
590
  backButton: {
453
- paddingVertical: 8,
454
- paddingHorizontal: 4
591
+ padding: 8
455
592
  },
456
593
  backButtonText: {
457
594
  fontSize: 18,
458
- fontFamily: _fonts.fontFamilies.phudu
595
+ fontFamily: _fonts.fontFamilies.phuduMedium
459
596
  },
460
597
  title: {
461
- fontSize: 20,
462
- fontFamily: _fonts.fontFamilies.phuduSemiBold,
598
+ fontSize: 24,
599
+ fontFamily: _fonts.fontFamilies.phuduBold,
463
600
  textAlign: 'center'
464
601
  },
465
- placeholder: {
466
- width: 60 // Same as back button to center title
602
+ headerSpacer: {
603
+ width: 40
467
604
  },
468
- scrollView: {
469
- flex: 1
470
- },
471
- scrollContainer: {
472
- padding: 20
605
+ content: {
606
+ flex: 1,
607
+ paddingHorizontal: 20
473
608
  },
474
- description: {
475
- marginBottom: 24
609
+ scrollContent: {
610
+ paddingBottom: 40
476
611
  },
477
- descriptionText: {
478
- fontSize: 14,
479
- fontFamily: _fonts.fontFamilies.phudu,
480
- lineHeight: 20
612
+ loadingContainer: {
613
+ flex: 1,
614
+ justifyContent: 'center',
615
+ alignItems: 'center',
616
+ paddingTop: 60
481
617
  },
482
- usersContainer: {
483
- marginBottom: 32
618
+ loadingText: {
619
+ marginTop: 16,
620
+ fontSize: 16,
621
+ fontFamily: _fonts.fontFamilies.phudu
484
622
  },
485
623
  sectionTitle: {
486
- fontSize: 16,
624
+ fontSize: 20,
487
625
  fontFamily: _fonts.fontFamilies.phuduSemiBold,
488
- marginBottom: 16
626
+ marginBottom: 20,
627
+ marginTop: 10
628
+ },
629
+ emptyState: {
630
+ alignItems: 'center',
631
+ paddingVertical: 40
632
+ },
633
+ emptyText: {
634
+ fontSize: 16,
635
+ fontFamily: _fonts.fontFamilies.phudu,
636
+ textAlign: 'center'
489
637
  },
490
- userItem: {
638
+ sessionCard: {
639
+ borderRadius: 16,
640
+ marginBottom: 16,
641
+ padding: 20,
642
+ shadowOffset: {
643
+ width: 0,
644
+ height: 2
645
+ },
646
+ shadowOpacity: 0.1,
647
+ shadowRadius: 8,
648
+ elevation: 3
649
+ },
650
+ sessionHeader: {
491
651
  flexDirection: 'row',
492
652
  alignItems: 'center',
493
- justifyContent: 'space-between',
494
- padding: 16,
495
- borderRadius: 12,
496
- borderWidth: 1,
497
- marginBottom: 12
653
+ marginBottom: 16
654
+ },
655
+ avatarContainer: {
656
+ position: 'relative',
657
+ marginRight: 16
658
+ },
659
+ avatar: {
660
+ width: 60,
661
+ height: 60,
662
+ borderRadius: 30
663
+ },
664
+ avatarPlaceholder: {
665
+ width: 60,
666
+ height: 60,
667
+ borderRadius: 30,
668
+ justifyContent: 'center',
669
+ alignItems: 'center'
670
+ },
671
+ avatarText: {
672
+ fontSize: 24,
673
+ fontFamily: _fonts.fontFamilies.phuduBold
674
+ },
675
+ activeBadge: {
676
+ position: 'absolute',
677
+ bottom: -2,
678
+ right: -2,
679
+ width: 20,
680
+ height: 20,
681
+ borderRadius: 10,
682
+ justifyContent: 'center',
683
+ alignItems: 'center'
684
+ },
685
+ activeBadgeText: {
686
+ color: 'white',
687
+ fontSize: 12,
688
+ fontFamily: _fonts.fontFamilies.phuduBold
498
689
  },
499
690
  userInfo: {
500
- flex: 1
691
+ flex: 1,
692
+ justifyContent: 'center'
501
693
  },
502
- username: {
503
- fontSize: 16,
694
+ displayName: {
695
+ fontSize: 18,
504
696
  fontFamily: _fonts.fontFamilies.phuduSemiBold,
505
697
  marginBottom: 4
506
698
  },
507
- email: {
699
+ username: {
508
700
  fontSize: 14,
509
701
  fontFamily: _fonts.fontFamilies.phudu,
510
- marginBottom: 8
511
- },
512
- activeBadge: {
513
- paddingHorizontal: 8,
514
- paddingVertical: 4,
515
- borderRadius: 6,
516
- alignSelf: 'flex-start'
702
+ marginBottom: 4
517
703
  },
518
- activeBadgeText: {
519
- color: '#FFFFFF',
704
+ lastActive: {
520
705
  fontSize: 12,
521
- fontFamily: _fonts.fontFamilies.phuduMedium
706
+ fontFamily: _fonts.fontFamilies.phudu
522
707
  },
523
- userActions: {
708
+ sessionActions: {
524
709
  flexDirection: 'row',
525
- gap: 8
710
+ justifyContent: 'space-between',
711
+ gap: 12
526
712
  },
527
713
  switchButton: {
528
- paddingHorizontal: 16,
529
- paddingVertical: 8,
530
- borderRadius: 8,
714
+ flex: 1,
715
+ paddingVertical: 12,
716
+ paddingHorizontal: 20,
531
717
  borderWidth: 1,
532
- minWidth: 70,
533
- alignItems: 'center'
718
+ borderRadius: 8,
719
+ alignItems: 'center',
720
+ justifyContent: 'center'
534
721
  },
535
722
  switchButtonText: {
536
723
  fontSize: 14,
537
- fontFamily: _fonts.fontFamilies.phuduMedium
724
+ fontFamily: _fonts.fontFamilies.phuduSemiBold
538
725
  },
539
726
  removeButton: {
540
- paddingHorizontal: 16,
541
- paddingVertical: 8,
542
- borderRadius: 8,
727
+ flex: 1,
728
+ paddingVertical: 12,
729
+ paddingHorizontal: 20,
543
730
  borderWidth: 1,
544
- minWidth: 70,
545
- alignItems: 'center'
731
+ borderRadius: 8,
732
+ alignItems: 'center',
733
+ justifyContent: 'center'
546
734
  },
547
735
  removeButtonText: {
548
736
  fontSize: 14,
549
- fontFamily: _fonts.fontFamilies.phuduMedium
737
+ fontFamily: _fonts.fontFamilies.phuduSemiBold
550
738
  },
551
- actionsContainer: {
739
+ actionsSection: {
740
+ marginTop: 40,
552
741
  gap: 16
553
742
  },
554
743
  actionButton: {
555
744
  paddingVertical: 16,
556
745
  paddingHorizontal: 20,
557
- borderRadius: 12,
558
746
  borderWidth: 1,
559
- alignItems: 'center'
747
+ borderRadius: 12,
748
+ alignItems: 'center',
749
+ justifyContent: 'center'
560
750
  },
561
751
  actionButtonText: {
562
752
  fontSize: 16,
563
- fontFamily: _fonts.fontFamilies.phuduMedium
753
+ fontFamily: _fonts.fontFamilies.phuduSemiBold
564
754
  },
565
755
  dangerButton: {
566
- paddingVertical: 16,
567
- paddingHorizontal: 20,
568
- borderRadius: 12,
569
- alignItems: 'center'
756
+ // Additional styles for danger buttons if needed
570
757
  },
571
758
  dangerButtonText: {
572
759
  fontSize: 16,
573
- fontFamily: _fonts.fontFamilies.phuduMedium
574
- },
575
- sectionHeader: {
576
- flexDirection: 'row',
577
- alignItems: 'center',
578
- justifyContent: 'space-between',
579
- marginBottom: 16
760
+ fontFamily: _fonts.fontFamilies.phuduSemiBold
580
761
  },
581
- toggleButton: {
582
- paddingHorizontal: 12,
583
- paddingVertical: 6,
584
- borderRadius: 6,
762
+ deviceManagementSection: {
763
+ marginTop: 20,
764
+ padding: 16,
765
+ borderRadius: 12,
585
766
  borderWidth: 1
586
- },
587
- toggleButtonText: {
588
- fontSize: 14,
589
- fontFamily: _fonts.fontFamilies.phuduMedium
590
- },
591
- loadingContainer: {
592
- flexDirection: 'row',
593
- alignItems: 'center',
594
- justifyContent: 'center',
595
- paddingVertical: 20,
596
- gap: 8
597
- },
598
- loadingText: {
599
- fontSize: 14,
600
- fontFamily: _fonts.fontFamilies.phudu
601
- },
602
- emptyText: {
603
- fontSize: 14,
604
- fontFamily: _fonts.fontFamilies.phudu,
605
- textAlign: 'center',
606
- paddingVertical: 20,
607
- fontStyle: 'italic'
608
767
  }
609
768
  });
610
- var _default = exports.default = AccountSwitcherScreen;
769
+ var _default = exports.default = ModernAccountSwitcherScreen;
611
770
  //# sourceMappingURL=AccountSwitcherScreen.js.map