-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add product announcements toggle (#11175)
<!-- Please submit this PR as a draft initially. Do not mark it as "Ready for review" until the template has been completely filled out, and PR status checks have passed at least once. --> ## **Description** This PR implements Product Announcement's toggle on custom notifications. [NOTIFY-1087](https://consensyssoftware.atlassian.net/browse/NOTIFY-1087?atlOrigin=eyJpIjoiYWM0MWY1M2ZjNGM5NDZjOGJiYTY3ZTdkYWEwYTBiMTkiLCJwIjoiaiJ9) ## **Related issues** Fixes: ## **Manual testing steps** 1. Go to Settings Page 2. Go to Notifications Settings ## **Screenshots/Recordings** <!-- If applicable, add screenshots and/or recordings to visualize the before and after of your change. --> ### **Before** <img width="334" alt="Screenshot 2024-09-10 at 9 15 37 PM" src="https://github.com/user-attachments/assets/31ba7472-1888-49e2-9a65-1d46208060db"> ### **After** ![Screenshot 2024-09-12 at 13 38 19](https://github.com/user-attachments/assets/1866bd9c-5c26-4c56-ae9f-efd18dee1351) ## **Pre-merge author checklist** - [ ] I’ve followed [MetaMask Contributor Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask Mobile Coding Standards](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/CODING_GUIDELINES.md). - [ ] I've completed the PR template to the best of my ability - [ ] I’ve included tests if applicable - [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format if applicable - [ ] I’ve applied the right labels on the PR (see [labeling guidelines](https://github.com/MetaMask/metamask-mobile/blob/main/.github/guidelines/LABELING_GUIDELINES.md)). Not required for external contributors. ## **Pre-merge reviewer checklist** - [ ] I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed). - [ ] I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots. [NOTIFY-1087]: https://consensyssoftware.atlassian.net/browse/NOTIFY-1087?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
- Loading branch information
1 parent
f8d2df6
commit 0b39b1f
Showing
7 changed files
with
208 additions
and
153 deletions.
There are no files selected for viewing
95 changes: 95 additions & 0 deletions
95
...s/Settings/NotificationsSettings/CustomNotificationsRow/__snapshots__/index.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`CustomNotificationsRow should render correctly 1`] = ` | ||
<View | ||
style={ | ||
{ | ||
"alignItems": "center", | ||
"flexDirection": "row", | ||
"marginBottom": 24, | ||
} | ||
} | ||
> | ||
<SvgMock | ||
color="#141618" | ||
height={24} | ||
name="Arrow2Upright" | ||
style={ | ||
{ | ||
"height": 24, | ||
"marginRight": 16, | ||
"width": 24, | ||
} | ||
} | ||
width={24} | ||
/> | ||
<View | ||
style={ | ||
{ | ||
"alignItems": "flex-start", | ||
"flex": 1, | ||
} | ||
} | ||
> | ||
<Text | ||
accessibilityRole="text" | ||
style={ | ||
{ | ||
"color": "#141618", | ||
"flex": 1, | ||
"fontFamily": "EuclidCircularB-Medium", | ||
"fontSize": 16, | ||
"fontWeight": "500", | ||
"letterSpacing": 0, | ||
"lineHeight": 24, | ||
} | ||
} | ||
> | ||
Assets Sent | ||
</Text> | ||
<Text | ||
accessibilityRole="text" | ||
style={ | ||
{ | ||
"color": "#141618", | ||
"flex": 1, | ||
"fontFamily": "EuclidCircularB-Medium", | ||
"fontSize": 16, | ||
"fontWeight": "500", | ||
"letterSpacing": 0, | ||
"lineHeight": 24, | ||
} | ||
} | ||
> | ||
Funds and NFT | ||
</Text> | ||
</View> | ||
<RCTSwitch | ||
accessibilityRole="switch" | ||
onChange={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
onTintColor="#0376c9" | ||
style={ | ||
[ | ||
{ | ||
"height": 31, | ||
"width": 51, | ||
}, | ||
[ | ||
{ | ||
"alignSelf": "flex-start", | ||
}, | ||
{ | ||
"backgroundColor": "#bbc0c566", | ||
"borderRadius": 16, | ||
}, | ||
], | ||
] | ||
} | ||
thumbTintColor="#ffffff" | ||
tintColor="#bbc0c566" | ||
value={false} | ||
/> | ||
</View> | ||
`; |
19 changes: 19 additions & 0 deletions
19
app/components/Views/Settings/NotificationsSettings/CustomNotificationsRow/index.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react'; | ||
import CustomNotificationsRow from '../CustomNotificationsRow/index'; | ||
import { render } from '@testing-library/react-native'; | ||
import notificationsRows from '../notificationsRows'; | ||
|
||
describe('CustomNotificationsRow', () => { | ||
it('should render correctly', () => { | ||
const { toJSON } = render( | ||
<CustomNotificationsRow | ||
title={notificationsRows[0].title} | ||
description={notificationsRows[0].description} | ||
icon={notificationsRows[0].icon} | ||
isEnabled={notificationsRows[0].value} | ||
onChange={()=> jest.fn()} | ||
/>, | ||
); | ||
expect(toJSON()).toMatchSnapshot(); | ||
}); | ||
}); |
64 changes: 64 additions & 0 deletions
64
app/components/Views/Settings/NotificationsSettings/CustomNotificationsRow/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import React from 'react'; | ||
import { Switch, View } from 'react-native'; | ||
import { useTheme } from '../../../../../util/theme'; | ||
import { createStyles } from '../NotificationOptionToggle/styles'; | ||
import Text, { | ||
TextVariant, | ||
} from '../../../../../component-library/components/Texts/Text'; | ||
import Icon, { IconColor, IconName, IconSize } from '../../../../../component-library/components/Icons/Icon'; | ||
|
||
interface CustomNotificationsRowProps { | ||
title: string; | ||
description?: string; | ||
icon: IconName; | ||
isEnabled: boolean; | ||
onChange: () => void; | ||
} | ||
|
||
const CustomNotificationsRow = ({ | ||
title, | ||
description, | ||
icon, | ||
isEnabled, | ||
onChange, | ||
}: CustomNotificationsRowProps) => { | ||
const theme = useTheme(); | ||
const { colors } = theme; | ||
const styles = createStyles(); | ||
|
||
return ( | ||
<View style={styles.container}> | ||
<Icon | ||
name={icon} | ||
style={styles.icon} | ||
color={IconColor.Default} | ||
size={IconSize.Lg} | ||
/> | ||
<View style={styles.titleContainer}> | ||
<Text variant={TextVariant.BodyLGMedium} style={styles.title}> | ||
{title} | ||
</Text> | ||
{ | ||
description && | ||
(<Text variant={TextVariant.BodyLGMedium} style={styles.title}> | ||
{description} | ||
</Text>) | ||
} | ||
</View> | ||
<Switch | ||
value={isEnabled} | ||
onChange={onChange} | ||
trackColor={{ | ||
true: colors.primary.default, | ||
false: colors.border.muted, | ||
}} | ||
thumbColor={theme.brandColors.white} | ||
style={styles.switch} | ||
ios_backgroundColor={colors.border.muted} | ||
/> | ||
</View> | ||
); | ||
}; | ||
|
||
|
||
export default React.memo(CustomNotificationsRow); |
114 changes: 0 additions & 114 deletions
114
...Settings/NotificationsSettings/NotificationOptionToggle/__snapshots__/index.test.tsx.snap
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
app/components/Views/Settings/NotificationsSettings/NotificationOptionToggle/index.test.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters