Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

improve announcements ui

ammarahm-edc1ed4a7e78b1
diff --git a/apps/mobile/src/components/announcements/cta.js b/apps/mobile/src/components/announcements/cta.js
index dc57ddd07..5cdce2366 100644
--- a/apps/mobile/src/components/announcements/cta.js
+++ b/apps/mobile/src/components/announcements/cta.js
@@ -1,15 +1,14 @@
import React from 'react';
-import { View } from 'react-native';
-import { useThemeStore } from '../../stores/theme';
+import { Linking, View } from 'react-native';
+import SettingsBackupAndRestore from '../../screens/settings/backup-restore';
import { eSendEvent, presentSheet } from '../../services/event-manager';
+import { useThemeStore } from '../../stores/theme';
import { eCloseAnnouncementDialog } from '../../utils/events';
-import { openLinkInBrowser } from '../../utils/functions';
import { SIZE } from '../../utils/size';
import { sleep } from '../../utils/time';
-import SettingsBackupAndRestore from '../../screens/settings/backup-restore';
-import { Button } from '../ui/button';
-import SheetProvider from '../sheet-provider';
import { PricingPlans } from '../premium/pricing-plans';
+import SheetProvider from '../sheet-provider';
+import { Button } from '../ui/button';
import { allowedOnPlatform, getStyle } from './functions';
export const Cta = ({ actions, style = {}, color, inline }) => {
@@ -22,9 +21,7 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
await sleep(500);
}
if (item.type === 'link') {
- try {
- await openLinkInBrowser(item.data, colors);
- } catch (e) {}
+ Linking.openURL(item.data).catch(console.log);
} else if (item.type === 'promo') {
presentSheet({
component: (
@@ -49,48 +46,101 @@ export const Cta = ({ actions, style = {}, color, inline }) => {
<View
style={{
paddingHorizontal: 12,
- ...getStyle(style)
+ ...getStyle(style),
+ flexDirection: inline ? 'row' : 'column'
}}
>
<SheetProvider context="premium_cta" />
- {buttons.length > 0 &&
- buttons.slice(0, 1).map(item => (
- <Button
- key={item.title}
- title={item.title}
- fontSize={SIZE.md}
- buttonType={{
- color: color ? color : colors.accent,
- text: colors.light,
- selected: color ? color : colors.accent,
- opacity: 1
- }}
- onPress={() => onPress(item)}
- width={'100%'}
- style={{
- marginBottom: 5
- }}
- />
- ))}
- {buttons.length > 1 &&
- buttons.slice(1, 2).map((item, index) => (
- <Button
- key={item.title}
- title={item.title}
- fontSize={SIZE.xs}
- type="gray"
- onPress={() => onPress(item)}
- width={null}
- height={20}
- style={{
- minWidth: '50%'
- }}
- textStyle={{
- textDecorationLine: 'underline'
- }}
- />
- ))}
+ {inline ? (
+ <>
+ {buttons.length > 0 &&
+ buttons.slice(0, 1).map(item => (
+ <Button
+ key={item.title}
+ title={item.title}
+ fontSize={SIZE.sm}
+ type="transparent"
+ textStyle={{
+ textDecorationLine: 'underline'
+ }}
+ onPress={() => onPress(item)}
+ bold
+ style={{
+ height: 30,
+ alignSelf: 'flex-start',
+ paddingHorizontal: 0,
+ marginTop: -6
+ }}
+ />
+ ))}
+
+ {buttons.length > 1 &&
+ buttons.slice(1, 2).map((item, index) => (
+ <Button
+ key={item.title}
+ title={item.title}
+ fontSize={SIZE.sm}
+ type="gray"
+ onPress={() => onPress(item)}
+ width={null}
+ height={30}
+ style={{
+ alignSelf: 'flex-start',
+ paddingHorizontal: 0,
+ marginTop: -6,
+ marginLeft: 12
+ }}
+ textStyle={{
+ textDecorationLine: 'underline'
+ }}
+ />
+ ))}
+ </>
+ ) : (
+ <>
+ {buttons.length > 0 &&
+ buttons.slice(0, 1).map(item => (
+ <Button
+ key={item.title}
+ title={item.title}
+ fontSize={SIZE.md}
+ buttonType={{
+ color: color ? color : colors.accent,
+ text: colors.light,
+ selected: color ? color : colors.accent,
+ opacity: 1
+ }}
+ onPress={() => onPress(item)}
+ width={250}
+ style={{
+ marginBottom: 5,
+ borderRadius: 100
+ }}
+ />
+ ))}
+
+ {buttons.length > 1 &&
+ buttons.slice(1, 2).map((item, index) => (
+ <Button
+ key={item.title}
+ title={item.title}
+ fontSize={SIZE.xs + 1}
+ type="gray"
+ onPress={() => onPress(item)}
+ width={null}
+ height={30}
+ style={{
+ minWidth: '50%',
+ marginTop: 5
+ }}
+ textStyle={{
+ textDecorationLine: 'underline'
+ }}
+ />
+ ))}
+ </>
+ )}
</View>
);
};
diff --git a/apps/mobile/src/components/announcements/description.js b/apps/mobile/src/components/announcements/description.js
index c1b808285..3c64be336 100644
--- a/apps/mobile/src/components/announcements/description.js
+++ b/apps/mobile/src/components/announcements/description.js
@@ -4,15 +4,16 @@ import { SIZE } from '../../utils/size';
import Paragraph from '../ui/typography/paragraph';
import { getStyle } from './functions';
-export const Description = ({ text, style = {} }) => {
+export const Description = ({ text, style = {}, inline }) => {
const colors = useThemeStore(state => state.colors);
return (
<Paragraph
- size={SIZE.md}
style={{
marginHorizontal: 12,
- ...getStyle(style)
+ ...getStyle(style),
+ textAlign: inline ? 'left' : style?.textAlign
}}
+ size={inline ? SIZE.sm : SIZE.md}
>
{text}
</Paragraph>
diff --git a/apps/mobile/src/components/announcements/index.js b/apps/mobile/src/components/announcements/index.js
index a14ec26b1..e27972d6f 100644
--- a/apps/mobile/src/components/announcements/index.js
+++ b/apps/mobile/src/components/announcements/index.js
@@ -51,7 +51,9 @@ export const AnnouncementDialog = () => {
maxHeight: DDS.isTab ? '90%' : '100%',
borderRadius: DDS.isTab ? 10 : 0,
overflow: 'hidden',
- marginBottom: DDS.isTab ? 20 : 0
+ marginBottom: DDS.isTab ? 20 : 0,
+ borderTopRightRadius: 10,
+ borderTopLeftRadius: 10
}}
>
<FlatList
diff --git a/apps/mobile/src/components/announcements/title.js b/apps/mobile/src/components/announcements/title.js
index 46e3d9250..4f3e89bd7 100644
--- a/apps/mobile/src/components/announcements/title.js
+++ b/apps/mobile/src/components/announcements/title.js
@@ -1,17 +1,69 @@
import React from 'react';
-import { useThemeStore } from '../../stores/theme';
+import { View } from 'react-native';
+import { useMessageStore } from '../../stores/stores';
+import { SIZE } from '../../utils/size';
+import { Button } from '../ui/button';
import Heading from '../ui/typography/heading';
import { getStyle } from './functions';
-export const Title = ({ text, style = {} }) => {
- const colors = useThemeStore(state => state.colors);
+export const Title = ({ text, style = {}, inline }) => {
+ const announcements = useMessageStore(state => state.announcements);
+ let announcement = announcements.length > 0 ? announcements[0] : null;
+ const remove = useMessageStore(state => state.remove);
- return (
+ return inline ? (
+ <View
+ style={{
+ flexDirection: 'row',
+ justifyContent: 'space-between',
+ alignItems: 'center',
+ marginBottom: inline ? 5 : 0
+ }}
+ >
+ <Heading
+ style={{
+ marginHorizontal: 12,
+ marginTop: 12,
+ ...getStyle(style),
+ textAlign: inline ? 'left' : style?.textAlign,
+ flexShrink: 1
+ }}
+ numberOfLines={1}
+ size={inline ? SIZE.md : SIZE.xl}
+ >
+ {inline ? text?.toUpperCase() : text}
+ </Heading>
+
+ <Button
+ type="gray"
+ icon="close"
+ height={null}
+ onPress={() => {
+ remove(announcement.id);
+ }}
+ hitSlop={{
+ left: 15,
+ top: 10,
+ bottom: 10,
+ right: 0
+ }}
+ iconSize={24}
+ fontSize={SIZE.xs + 1}
+ style={{
+ borderRadius: 100,
+ paddingVertical: 0,
+ paddingHorizontal: 0,
+ marginRight: 12,
+ zIndex: 10
+ }}
+ />
+ </View>
+ ) : (
<Heading
style={{
marginHorizontal: 12,
- marginTop: 12,
- ...getStyle(style)
+ ...getStyle(style),
+ marginTop: style.marginTop || 12
}}
>
{text}
diff --git a/apps/mobile/src/components/launcher/index.js b/apps/mobile/src/components/launcher/index.js
index 841ac51c3..4a400cb0e 100644
--- a/apps/mobile/src/components/launcher/index.js
+++ b/apps/mobile/src/components/launcher/index.js
@@ -130,13 +130,15 @@ const Launcher = () => {
if (await checkForRateAppRequest()) return;
if (await checkNeedsBackup()) return;
if (await PremiumService.getRemainingTrialDaysStatus()) return;
-
await useMessageStore.getState().setAnnouncement();
- if (!requireIntro) {
- let dialogs = useMessageStore.getState().dialogs;
- if (dialogs.length > 0) {
- eSendEvent(eOpenAnnouncementDialog, dialogs[0]);
- }
+
+ if (!requireIntro.value) {
+ useMessageStore.subscribe(state => {
+ let dialogs = state.announcements;
+ if (dialogs.length > 0) {
+ eSendEvent(eOpenAnnouncementDialog, dialogs[0]);
+ }
+ });
}
};