mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-01 00:07:01 +00:00
feat: select a message by tapping its avatar in the list #91
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
|
||||
// Selecting mail needed a long press; native #91 asks for a tap on the
|
||||
// left side, as the webmail's avatar does.
|
||||
|
||||
describe('list row avatar (#91)', () => {
|
||||
it('toggles the row into the selection on a tap', () => {
|
||||
const src = fs.readFileSync(path.resolve(__dirname, '../../screens/EmailListScreen.tsx'), 'utf8');
|
||||
const avatar = src.slice(src.indexOf('{density.showAvatar && ('), src.indexOf('{/* Content */}'));
|
||||
expect(avatar).toMatch(/<Pressable\s+onPress=\{handleLongPress\}/);
|
||||
expect(avatar).toMatch(/accessibilityRole="checkbox"/);
|
||||
expect(avatar).toMatch(/accessibilityState=\{\{ checked: selected \}\}/);
|
||||
expect(avatar).toMatch(/<SenderAvatar/);
|
||||
});
|
||||
});
|
||||
@@ -228,13 +228,27 @@ const EmailRow = React.memo(function EmailRow({
|
||||
</View>
|
||||
)}
|
||||
{density.showAvatar && (
|
||||
<SenderAvatar
|
||||
name={senderName}
|
||||
email={senderEmail}
|
||||
size={componentSizes.avatarMd}
|
||||
disableImages={disableAvatarImages}
|
||||
senderWarning={senderWarning}
|
||||
/>
|
||||
// A tap on the avatar picks the row and starts selection mode, like
|
||||
// a long press (#91).
|
||||
<Pressable
|
||||
onPress={handleLongPress}
|
||||
hitSlop={4}
|
||||
accessibilityRole="checkbox"
|
||||
accessibilityState={{ checked: selected }}
|
||||
accessibilityLabel={tr('email_list.batch_actions.select_row', 'Select {sender}: {subject}', {
|
||||
sender: senderName,
|
||||
subject: singleLine(item.subject) || tr('email_viewer.no_subject', '(No Subject)'),
|
||||
})}
|
||||
testID="email-row-avatar"
|
||||
>
|
||||
<SenderAvatar
|
||||
name={senderName}
|
||||
email={senderEmail}
|
||||
size={componentSizes.avatarMd}
|
||||
disableImages={disableAvatarImages}
|
||||
senderWarning={senderWarning}
|
||||
/>
|
||||
</Pressable>
|
||||
)}
|
||||
|
||||
{/* Content */}
|
||||
|
||||
Reference in New Issue
Block a user