Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: pressable card title #4191

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

mtch99
Copy link

@mtch99 mtch99 commented Nov 20, 2023

Motivation

I needed the option to press the card title

Test plan

Two test cases on the Card.Title component
- Card.Title without onPressTitle props {...props, onPressTitle:undefined}
make sure the card functions normally
- Card.Title with onPressTitle props = () => {Alert.alert("Pressed")}

Both are tested in the Card example馃憞
Capture d鈥檈虂cran, le 2023-11-19 a虁 23 18 44

After press event on card title

Capture d鈥檈虂cran, le 2023-11-19 a虁 23 20 32

@callstack-bot
Copy link

callstack-bot commented Nov 20, 2023

Hey @mtch99, thank you for your pull request 馃. The documentation from this branch can be viewed here.

@mtch99 mtch99 changed the title Feat/pressable card title feat: pressable card title Nov 22, 2023
@@ -169,7 +176,18 @@ const CardTitle = ({
) : null}

<View style={[styles.titles]}>
{title && (
{title && onPressTitle ? (
<TouchableOpacity onPress={onPressTitle} style={[styles.title]}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid code repetition and move the title outside the render then used wrapped in pressable and without it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After moving the Title component from the render, I did the same for subtitle to keep preserve coding style consistency, also had to rename some variables

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are the changes okay? Or Is there something I have to correct? @lukewalczak

@@ -169,7 +176,18 @@ const CardTitle = ({
) : null}

<View style={[styles.titles]}>
{title && (
{title && onPressTitle ? (
<TouchableOpacity onPress={onPressTitle} style={[styles.title]}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Pressable instead of TouchableOpacity

@lukewalczak lukewalczak added this to the 5.12.0 milestone Jan 8, 2024
@lukewalczak lukewalczak removed this from the 5.12.0 milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants