Skip to content

Commit

Permalink
💄 - Improve urgent message title display (#335)
Browse files Browse the repository at this point in the history
- truncate urgent message title
- remove html tags and entities from message body
- announcement card darker background
  • Loading branch information
guytepper authored Oct 8, 2023
1 parent 5b1c61b commit 14de22f
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 33 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ android {
applicationId "com.betterrail"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 73
versionName "2.2.0"
versionCode 74
versionName "2.2.1"
missingDimensionStrategy "store", "play"
}

Expand Down
8 changes: 5 additions & 3 deletions app/components/announcements/announcement-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import TouchableScale from "react-native-touchable-scale"
import { fontScale, spacing, color } from "../../theme"
import { Text } from "../text/text"
import { openLink } from "../../utils/helpers/open-link"
import { removeHtmlTagsAndEntities } from "./announcements-utils"

const ANNOUNCEMENT_CARD: ViewStyle = {
minHeight: 80 * fontScale,
Expand All @@ -12,7 +13,7 @@ const ANNOUNCEMENT_CARD: ViewStyle = {
paddingHorizontal: spacing[3],

borderRadius: Platform.select({ ios: 12, android: 8 }),
backgroundColor: Platform.select({ ios: color.tertiaryBackground, android: color.inputBackground }),
backgroundColor: Platform.select({ ios: color.secondaryBackground, android: color.inputBackground }),
shadowColor: color.palette.black,
shadowOffset: { height: 0, width: 0 },
shadowOpacity: 0.05,
Expand All @@ -21,7 +22,7 @@ const ANNOUNCEMENT_CARD: ViewStyle = {

const TITLE_STYLE: TextStyle = {
fontFamily: "Heebo",
color: color.primary,
color: color.primaryLighter,
fontSize: 16,
marginBottom: spacing[0],
}
Expand All @@ -41,7 +42,8 @@ export const AnnouncementCard = ({ title, body, link }: AnnouncementCardProps) =
<TouchableScale activeScale={0.98} friction={10} disabled={!link} onPress={() => openLink(link)}>
<View style={ANNOUNCEMENT_CARD}>
{title && <Text style={TITLE_STYLE}>{title}</Text>}
<Text style={BODY_STYLE}>{body}</Text>

<Text style={BODY_STYLE}>{removeHtmlTagsAndEntities(body)}</Text>
</View>
</TouchableScale>
)
6 changes: 6 additions & 0 deletions app/components/announcements/announcements-utils.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Remove HTML tags and HTML entities from a given string.
*/
export function removeHtmlTagsAndEntities(input: string) {
return input.replace(/<[^>]+>|&[^;]+;/g, "")
}
5 changes: 3 additions & 2 deletions app/components/announcements/urgent-announcements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Text } from "../text/text"
import { Screen } from "../screen/screen"
import { useIsDarkMode } from "../../hooks"
import { AnnouncementCard } from "./announcement-card"
import { removeHtmlTagsAndEntities } from "./announcements-utils"

export const UrgentAnnouncements = () => {
const isDarkMode = useIsDarkMode()
Expand All @@ -17,8 +18,8 @@ export const UrgentAnnouncements = () => {
<Screen unsafe statusBar={Platform.select({ ios: "light-content" })} statusBarBackgroundColor={isDarkMode ? "#000" : "#fff"}>
<Text style={{ fontSize: 48, textAlign: "center", marginVertical: spacing[4] }}>📣</Text>
<View style={{ paddingHorizontal: spacing[4] }}>
{messages?.map((m) => (
<AnnouncementCard body={m.messageBody} />
{messages?.map((message, index) => (
<AnnouncementCard body={message.messageBody} key={index} />
))}
</View>
</Screen>
Expand Down
18 changes: 17 additions & 1 deletion app/screens/planner/Important-announcement-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withDelay, withTiming } fro
import { color, fontScale } from "../../theme"
import { useNavigation } from "@react-navigation/native"
import analytics from "@react-native-firebase/analytics"
import { removeHtmlTagsAndEntities } from "../../components/announcements/announcements-utils"

const TEXT_STYLE: TextStyle = {
color: color.whiteText,
Expand Down Expand Up @@ -63,8 +64,23 @@ export function ImportantAnnouncementBar({ title }: { title: string }) {
onPress={navigateToAnnouncements}
>
<Animated.Text style={[TEXT_STYLE, TextAnimatedStyle]} maxFontSizeMultiplier={1.15}>
{title}
{truncateString(removeHtmlTagsAndEntities(title), 5)}
</Animated.Text>
</AnimatedTouchable>
)
}

function truncateString(inputString, numWords) {
// Split the input string into an array of words
const words = inputString.split(" ")

// Take the first 'numWords' words and join them back into a string
const truncatedString = words.slice(0, numWords).join(" ")

// Add "..." to the end if there are more words in the original string
if (words.length > numWords) {
return truncatedString + " ..."
} else {
return truncatedString
}
}
40 changes: 20 additions & 20 deletions ios/BetterRail.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1156,14 +1156,14 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = BetterRail/BetterRailDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = BetterRail/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1196,13 +1196,13 @@
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
INFOPLIST_FILE = BetterRail/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 13.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -1359,14 +1359,14 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = WatchBetterRail_Extension;
INFOPLIST_FILE = WatchBetterRail/Info.plist;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1401,14 +1401,14 @@
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
IBSC_MODULE = WatchBetterRail_Extension;
INFOPLIST_FILE = WatchBetterRail/Info.plist;
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp";
Expand Down Expand Up @@ -1437,15 +1437,15 @@
CODE_SIGN_ENTITLEMENTS = "WatchBetterRail Extension/WatchBetterRail Extension.entitlements";
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX;
ENABLE_PREVIEWS = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "WatchBetterRail Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1478,15 +1478,15 @@
"CODE_SIGN_IDENTITY[sdk=watchos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=watchos*]" = UE6BVYPPFX;
ENABLE_PREVIEWS = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = "WatchBetterRail Extension/Info.plist";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.watchkitapp.watchkitextension";
Expand Down Expand Up @@ -1516,15 +1516,15 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = BetterRailWidgetExtensionDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = BetterRailWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1557,15 +1557,15 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = BetterRailWidget/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 16.2;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.BetterRailWidget";
Expand All @@ -1590,15 +1590,15 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_ENTITLEMENTS = StationIntent/StationIntentDebug.entitlements;
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = StationIntent/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_DEBUG";
Expand Down Expand Up @@ -1629,15 +1629,15 @@
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Distribution";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 3;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=iphoneos*]" = UE6BVYPPFX;
GCC_C_LANGUAGE_STANDARD = gnu11;
INFOPLIST_FILE = StationIntent/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks";
MARKETING_VERSION = 2.2.0;
MARKETING_VERSION = 2.2.1;
MTL_FAST_MATH = YES;
OTHER_SWIFT_FLAGS = "$(inherited) -D EXPO_CONFIGURATION_RELEASE";
PRODUCT_BUNDLE_IDENTIFIER = "il.co.better-rail.StationIntent";
Expand Down
2 changes: 1 addition & 1 deletion ios/BetterRail/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>3</string>
<key>ITSAppUsesNonExemptEncryption</key>
<false/>
<key>LSApplicationQueriesSchemes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/BetterRailWidget/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>3</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionPointIdentifier</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/StationIntent/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>3</string>
<key>NSExtension</key>
<dict>
<key>NSExtensionAttributes</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/WatchBetterRail Extension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>3</string>
<key>CLKComplicationPrincipalClass</key>
<string>$(PRODUCT_MODULE_NAME).ComplicationController</string>
<key>NSExtension</key>
Expand Down
2 changes: 1 addition & 1 deletion ios/WatchBetterRail/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>10</string>
<string>3</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
Expand Down

0 comments on commit 14de22f

Please sign in to comment.