Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,44 @@ jobs:

- name: Merge Coverage Reports
run: |
mkdir -p coverage
# Use the web coverage as primary (it has the most source)
if [ -f coverage/web/lcov.info ]; then
cp coverage/web/lcov.info coverage/lcov.info
fi
# Append shared coverage if it exists
if [ -f coverage/shared/lcov.info ]; then
cat coverage/shared/lcov.info >> coverage/lcov.info
fi
node <<'NODE'
const fs = require('fs')
const path = require('path')

const reports = [
{ file: 'coverage/web/lcov.info', prefix: 'apps/web' },
{ file: 'coverage/mobile/lcov.info', prefix: 'apps/mobile' },
{ file: 'coverage/shared/lcov.info', prefix: 'packages/shared' },
]

const outputPath = path.join('coverage', 'lcov.info')
fs.mkdirSync(path.dirname(outputPath), { recursive: true })

const merged = []

for (const report of reports) {
if (!fs.existsSync(report.file)) continue

const content = fs.readFileSync(report.file, 'utf8')
const lines = content.split(/\r?\n/)

for (const line of lines) {
if (!line.startsWith('SF:')) {
merged.push(line)
continue
}

const sourceFile = line.slice(3).replace(/\\/g, '/')
const normalized = sourceFile.startsWith(report.prefix)
? sourceFile
: `${report.prefix}/${sourceFile}`

merged.push(`SF:${normalized}`)
}
}

fs.writeFileSync(outputPath, merged.join('\n'))
NODE

- name: SonarCloud Scan
uses: SonarSource/sonarqube-scan-action@fd88b7d7ccbaefd23d8f36f73b59db7a3d246602 # v6
Expand Down
4 changes: 2 additions & 2 deletions apps/mobile/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "1.0.0",
"sdkVersion": "54.0.0",
"orientation": "portrait",
"icon": "./assets/icon.png",
"icon": "./assets/logo.png",
"userInterfaceStyle": "automatic",
"scheme": "orbit",
"newArchEnabled": true,
Expand All @@ -24,7 +24,7 @@
},
"android": {
"adaptiveIcon": {
"foregroundImage": "./assets/adaptive-icon.png",
"foregroundImage": "./assets/logo.png",
"backgroundColor": "#07060e"
},
"package": "org.useorbit.app",
Expand Down
29 changes: 24 additions & 5 deletions apps/mobile/app/streak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Text,
TouchableOpacity,
StyleSheet,
SafeAreaView,

Check warning on line 7 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'SafeAreaView' is deprecated.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGig&open=AZ1i_EqV2PhC6AteQGig&pullRequest=12
ScrollView,
Modal,
} from 'react-native'
Expand All @@ -25,7 +25,7 @@
// Streak Screen
// ---------------------------------------------------------------------------

export default function StreakScreen() {

Check failure on line 28 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Refactor this function to reduce its Cognitive Complexity from 24 to the 15 allowed.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGih&open=AZ1i_EqV2PhC6AteQGih&pullRequest=12
const { t, i18n } = useTranslation()
const { colors } = useAppTheme()
const router = useRouter()
Expand All @@ -50,7 +50,7 @@
return ''
}, [streak, t])

const tier = useMemo(() => {

Check warning on line 53 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this useless assignment to variable "tier".

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGii&open=AZ1i_EqV2PhC6AteQGii&pullRequest=12
if (streak >= 100) return 'legendary'
if (streak >= 30) return 'intense'
if (streak >= 7) return 'strong'
Expand Down Expand Up @@ -137,7 +137,7 @@
}

return (
<SafeAreaView style={styles.safeArea}>

Check warning on line 140 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'SafeAreaView' is deprecated.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGij&open=AZ1i_EqV2PhC6AteQGij&pullRequest=12
<ScrollView
style={styles.container}
contentContainerStyle={styles.scrollContent}
Expand Down Expand Up @@ -273,7 +273,7 @@
</Svg>
<Text style={styles.freezeTitle}>{t('streakDisplay.freeze.title')}</Text>
</View>
<Text style={styles.freezeAvailable}>
<Text style={styles.freezeAvailable} numberOfLines={2}>
{plural(
t('streakDisplay.freeze.available', { count: freezesAvailable }),
freezesAvailable,
Expand All @@ -289,21 +289,21 @@
</Svg>
<Text style={styles.frozenTodayText}>{t('streakDisplay.freeze.activeToday')}</Text>
</View>
) : streak > 0 ? (
<TouchableOpacity
style={[
styles.freezeButton,
!canFreeze && styles.freezeButtonDisabled,
]}
disabled={!canFreeze}
onPress={() => setShowConfirm(true)}
activeOpacity={0.8}
>
<Text style={[styles.freezeButtonText, !canFreeze && { color: colors.textMuted }]}>
{t('streakDisplay.freeze.activate')}
</Text>
</TouchableOpacity>
) : null}

Check warning on line 306 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Extract this nested ternary operation into an independent statement.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGik&open=AZ1i_EqV2PhC6AteQGik&pullRequest=12

{/* Already completed today hint */}
{hasCompletedToday && !isFrozenToday && streak > 0 ? (
Expand Down Expand Up @@ -387,7 +387,7 @@
</View>
</Modal>
<StreakFreezeCelebration ref={freezeCelebrationRef} />
</SafeAreaView>

Check warning on line 390 in apps/mobile/app/streak.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'SafeAreaView' is deprecated.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_EqV2PhC6AteQGil&open=AZ1i_EqV2PhC6AteQGil&pullRequest=12
)
}

Expand Down Expand Up @@ -542,12 +542,31 @@
// Freeze
freezeHeaderRow: {
flexDirection: 'row',
alignItems: 'center',
alignItems: 'flex-start',
justifyContent: 'space-between',
gap: 12,
},
freezeIconRow: {
flexDirection: 'row',
alignItems: 'center',
gap: 8,
flex: 1,
minWidth: 0,
},
freezeTitle: {
flexShrink: 1,
fontSize: 14,
fontWeight: '700',
color: colors.textPrimary,
},
freezeAvailable: {
flexShrink: 1,
maxWidth: '46%',
fontSize: 11,
lineHeight: 15,
color: colors.textMuted,
textAlign: 'right',
},
freezeIconRow: { flexDirection: 'row', alignItems: 'center', gap: 8 },
freezeTitle: { fontSize: 14, fontWeight: '700', color: colors.textPrimary },
freezeAvailable: { fontSize: 12, color: colors.textMuted },

frozenTodayBadge: {
flexDirection: 'row',
Expand Down
Binary file added apps/mobile/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions apps/mobile/components/bottom-sheet-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
// BottomSheetModal -- wrapper around @gorhom/bottom-sheet
// ---------------------------------------------------------------------------

export function BottomSheetModal({
open,
onClose,
title,
snapPoints: snapPointsProp,
children,
}: BottomSheetModalProps) {

Check warning on line 33 in apps/mobile/components/bottom-sheet-modal.tsx

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Mark the props of the component as read-only.

See more on https://sonarcloud.io/project/issues?id=thomasluizon_orbit-ui-mobile&issues=AZ1i_Es42PhC6AteQGim&open=AZ1i_Es42PhC6AteQGim&pullRequest=12
const { colors } = useAppTheme()
const styles = useMemo(() => createStyles(colors), [colors])
const bottomSheetRef = useRef<BottomSheet>(null)
Expand Down Expand Up @@ -79,6 +79,7 @@
snapPoints={snapPoints}
onChange={handleSheetChanges}
backdropComponent={renderBackdrop}
enableContentPanningGesture={false}
enablePanDownToClose
backgroundStyle={styles.background}
handleIndicatorStyle={styles.handleIndicator}
Expand Down Expand Up @@ -130,6 +131,7 @@
},
contentContainer: {
flex: 1,
minHeight: 0,
},
header: {
flexDirection: 'row',
Expand All @@ -156,6 +158,7 @@
},
body: {
flex: 1,
minHeight: 0,
paddingHorizontal: 20,
paddingTop: 16,
},
Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/components/habits/create-habit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
Text,
TextInput,
TouchableOpacity,
ScrollView,
ActivityIndicator,
StyleSheet,
} from "react-native";
import { BottomSheetScrollView } from "@gorhom/bottom-sheet";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { Trash2, Plus } from "lucide-react-native";
import { useTranslation } from "react-i18next";
Expand Down Expand Up @@ -268,7 +268,7 @@ export function CreateHabitModal({
}
snapPoints={["80%", "95%"]}
>
<ScrollView
<BottomSheetScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContent}
showsVerticalScrollIndicator={false}
Expand Down Expand Up @@ -366,7 +366,7 @@ export function CreateHabitModal({
</Text>
</TouchableOpacity>
</View>
</ScrollView>
</BottomSheetScrollView>
</BottomSheetModal>
);
}
Expand Down
17 changes: 11 additions & 6 deletions apps/mobile/components/habits/edit-habit-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ import {
View,
Text,
TouchableOpacity,
ScrollView,
ActivityIndicator,
StyleSheet,
} from "react-native";
import { BottomSheetScrollView } from "@gorhom/bottom-sheet";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { useTranslation } from "react-i18next";
import { BottomSheetModal } from "@/components/bottom-sheet-modal";
import { HabitFormFields } from "./habit-form-fields";
Expand Down Expand Up @@ -43,8 +44,9 @@ export function EditHabitModal({
habit,
}: Readonly<EditHabitModalProps>) {
const { t } = useTranslation();
const insets = useSafeAreaInsets();
const { colors } = useAppTheme();
const styles = useMemo(() => createStyles(colors), [colors]);
const styles = useMemo(() => createStyles(colors, insets.bottom), [colors, insets.bottom]);
const updateHabit = useUpdateHabit();
const assignTags = useAssignTags();

Expand Down Expand Up @@ -178,7 +180,7 @@ export function EditHabitModal({
title={t("habits.editHabit")}
snapPoints={["80%", "95%"]}
>
<ScrollView
<BottomSheetScrollView
style={styles.scroll}
contentContainerStyle={styles.scrollContent}
showsVerticalScrollIndicator={false}
Expand Down Expand Up @@ -236,7 +238,7 @@ export function EditHabitModal({
</Text>
</TouchableOpacity>
</View>
</ScrollView>
</BottomSheetScrollView>
</BottomSheetModal>
);
}
Expand All @@ -245,13 +247,16 @@ export function EditHabitModal({
// Styles
// ---------------------------------------------------------------------------

function createStyles(colors: ReturnType<typeof useAppTheme>["colors"]) {
function createStyles(
colors: ReturnType<typeof useAppTheme>["colors"],
bottomInset: number,
) {
return StyleSheet.create({
scroll: {
flex: 1,
},
scrollContent: {
paddingBottom: 40,
paddingBottom: bottomInset + 120,
gap: 20,
},
errorText: {
Expand Down
Loading
Loading