Skip to content

Commit

Permalink
merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
agjini committed Jul 28, 2023
2 parents 7a6c769 + 62179fe commit 983a611
Show file tree
Hide file tree
Showing 46 changed files with 1,236 additions and 1,040 deletions.
6 changes: 6 additions & 0 deletions app/assets/icons/seat.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed app/assets/logo_mini.png
Binary file not shown.
Binary file removed app/assets/logo_orange.png
Binary file not shown.
Binary file removed app/assets/logo_white.png
Binary file not shown.
Binary file removed app/assets/logo_yellow.png
Binary file not shown.
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@microsoft/signalr": "^7.0.2",
"@notifee/react-native": "^7.4.0",
"@react-native-async-storage/async-storage": "^1.17.11",
"@react-native-community/datetimepicker": "^7.0.1",
"@react-native-community/datetimepicker": "^7.4.1",
"@react-native-community/hooks": "^3.0.0",
"@react-native-firebase/app": "^16.5.1",
"@react-native-firebase/messaging": "^16.5.1",
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export type RallyingPoint = Identity &
export type LianeRequest = Identity &
Readonly<{
departureTime: UTCDateTime;
returnTime?: UTCDateTime;
returnTime?: UTCDateTime | null;
availableSeats: number;
from: Ref<RallyingPoint>;
to: Ref<RallyingPoint>;
Expand Down
2 changes: 1 addition & 1 deletion app/src/api/location.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LatLng } from "@/api/index";
import { MAPBOX_KEY, MAPTILER_KEY } from "@env";
import { MAPTILER_KEY } from "@env";
import { BoundingBox } from "@/api/geo";

export const DEFAULT_TLS = {
Expand Down
60 changes: 49 additions & 11 deletions app/src/api/service/location.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,27 @@ import Geolocation from "react-native-geolocation-service";
import { retrieveAsync, storeAsync } from "@/api/storage";
import { DEFAULT_TLS } from "@/api/location";
import { MAPTILER_KEY } from "@env";
import { Feature, FeatureCollection } from "geojson";
import { Feature, Geometry, Point } from "geojson";
export interface LocationService {
currentLocation(): Promise<LatLng>;

getLastKnownLocation(): LatLng;
cacheRecentLocation(rallyingPoint: RallyingPoint): Promise<RallyingPoint[]>;
getRecentLocations(): Promise<RallyingPoint[]>;

cacheRecentPlaceLocation(rallyingPoint: Feature): Promise<Feature[]>;
getRecentPlaceLocations(): Promise<Feature[]>;
cacheRecentPlaceLocation(rallyingPoint: SearchedLocation): Promise<SearchedLocation[]>;
getRecentPlaceLocations(): Promise<SearchedLocation[]>;

cacheRecentTrip(trip: Trip): Promise<Trip[]>;
getRecentTrips(): Promise<Trip[]>;

search(query: string, closeTo?: LatLng): Promise<FeatureCollection>;
search(
query: string,
closeTo?: LatLng
): Promise<{
type: "FeatureCollection";
features: Array<SearchedLocationSuggestion>;
}>;
}

export type Trip = {
Expand Down Expand Up @@ -123,18 +129,22 @@ export class LocationServiceClient implements LocationService {
return (await retrieveAsync<RallyingPoint[]>(rallyingPointsKey)) ?? [];
}

async cacheRecentPlaceLocation(p: Feature): Promise<Feature[]> {
let cachedValues = (await retrieveAsync<Feature[]>(recentPlacesKey)) ?? [];
cachedValues = cachedValues.filter(v => (v.properties!.ref || v.properties!.id) !== (p.properties!.ref || p.properties!.id));
async cacheRecentPlaceLocation(p: SearchedLocation): Promise<SearchedLocation[]> {
let cachedValues = (await retrieveAsync<SearchedLocation[]>(recentPlacesKey)) ?? [];
cachedValues = cachedValues.filter(
v =>
(isRallyingPointSearchedLocation(v) ? v.properties!.id : v.properties!.ref) !==
(isRallyingPointSearchedLocation(p) ? p.properties!.id : p.properties!.ref)
);
cachedValues.unshift(p);
cachedValues = cachedValues.slice(0, cacheSize);
await storeAsync<Feature[]>(recentPlacesKey, cachedValues);
await storeAsync<SearchedLocation[]>(recentPlacesKey, cachedValues);

return cachedValues;
}

async getRecentPlaceLocations(): Promise<Feature[]> {
return (await retrieveAsync<Feature[]>(recentPlacesKey)) ?? [];
async getRecentPlaceLocations(): Promise<SearchedLocation[]> {
return (await retrieveAsync<SearchedLocation[]>(recentPlacesKey)) ?? [];
}

async cacheRecentTrip(trip: Trip): Promise<Trip[]> {
Expand Down Expand Up @@ -176,7 +186,13 @@ export class LocationServiceClient implements LocationService {
return this.lastKnownLocation;
}

async search(query: string, closeTo?: LatLng): Promise<FeatureCollection> {
async search(
query: string,
closeTo?: LatLng
): Promise<{
type: "FeatureCollection";
features: Array<SearchedLocationSuggestion>;
}> {
let url = `https://api.maptiler.com/geocoding/${query}.json`;

const types = [
Expand Down Expand Up @@ -211,3 +227,25 @@ export class LocationServiceClient implements LocationService {
}
}
}
export type SearchedLocation = RallyingPointSearchedLocation | SearchedLocationSuggestion;
export type RallyingPointSearchedLocation = Feature<Point, RallyingPoint> & { place_type: ["rallying_point"] };
export type SearchedLocationSuggestion = Readonly<
{
place_type_name: string[] | undefined;
place_name: string;
place_type: string[];
context: Array<{ text: string }>;
} & Feature<Geometry, { ref: string; categories: string[] }>
>;
export function isRallyingPointSearchedLocation(item: SearchedLocation): item is RallyingPointSearchedLocation {
return item.place_type[0] === "rallying_point";
}

export function asSearchedLocation(rp: RallyingPoint): SearchedLocation {
return {
type: "Feature",
geometry: { type: "Point", coordinates: [rp.location.lng, rp.location.lat] },
properties: { ...rp },
place_type: ["rallying_point"]
};
}
3 changes: 3 additions & 0 deletions app/src/api/service/notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ export async function initializePushNotification(user: FullUser, authService: Au
// Update server's token
await authService.updatePushToken(pushToken);
}
PushNotifications?.onTokenRefresh(async (pushToken) => {
await authService.updatePushToken(pushToken);
});
PushNotifications?.onMessage(onMessageReceived);
return true;
} catch (e) {
Expand Down
4 changes: 2 additions & 2 deletions app/src/components/ActionItem.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AppPressableOverlay } from "@/components/base/AppPressable";
import { Row } from "@/components/base/AppLayout";
import { AppIcon, CustomIconName, IconName } from "@/components/base/AppIcon";
import { AppIcon, IconName } from "@/components/base/AppIcon";
import { AppText } from "@/components/base/AppText";
import { ColorValue, StyleSheet, View } from "react-native";
import React from "react";
Expand All @@ -9,7 +9,7 @@ import { AppColorPalettes, AppColors, WithAlpha } from "@/theme/colors";
export interface ActionItemProps {
onPress: () => void;
color?: ColorValue;
iconName: IconName | CustomIconName;
iconName: IconName;
text: string;
}
export const ActionItem = ({ onPress, color = AppColorPalettes.gray[800], iconName, text }: ActionItemProps) => (
Expand Down
29 changes: 16 additions & 13 deletions app/src/components/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useContext, useEffect } from "react";
import { createNativeStackNavigator } from "@react-navigation/native-stack";
import { createBottomTabNavigator } from "@react-navigation/bottom-tabs";
import { Pressable, StyleSheet, View } from "react-native";
import { Pressable, StyleProp, StyleSheet, View, ViewStyle } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
import { AppContext } from "@/components/ContextProvider";
import { AppIcon, IconName } from "@/components/base/AppIcon";
Expand All @@ -12,7 +12,6 @@ import { AppText } from "@/components/base/AppText";
import MyTripsScreen from "@/screens/user/MyTripsScreen";
import LianeIcon from "@/assets/icon.svg";
import SignUpScreen from "@/screens/signUp/SignUpScreen";
import { LianeInvitationScreen } from "@/screens/LianeInvitationScreen";
import { Row } from "@/components/base/AppLayout";
import { ProfileScreen } from "@/screens/user/ProfileScreen";
import { ChatScreen } from "@/screens/ChatScreen";
Expand Down Expand Up @@ -122,7 +121,6 @@ function Navigation() {
<Stack.Screen name="Publish" component={PublishScreen} options={{ headerShown: false, animation: "fade" }} />
<Stack.Screen name="LianeDetail" component={LianeDetailScreen} options={{ headerShown: false }} />
<Stack.Screen name="Chat" component={ChatScreen} options={{ headerShown: false }} />
<Stack.Screen name="LianeInvitation" component={LianeInvitationScreen} options={{ headerShown: false }} />
<Stack.Screen name="Profile" component={ProfileScreen} options={{ headerShown: false }} />
<Stack.Screen name="RequestJoin" component={RequestJoinScreen} options={{ headerShown: false, presentation: "modal" }} />
<Stack.Screen name="OpenJoinLianeRequest" component={OpenJoinRequestScreen} options={{ headerShown: false, presentation: "modal" }} />
Expand All @@ -142,25 +140,29 @@ function Navigation() {
type HomeScreenHeaderProp = {
label: string;
isRootHeader?: boolean;
style?: StyleProp<ViewStyle>;
};

const PageTitle = ({ title }: { title: string }) => <AppText style={{ fontSize: 22, fontWeight: "500", color: AppColors.darkBlue }}>{title}</AppText>;

export const HomeScreenHeader = ({ label, isRootHeader = false }: HomeScreenHeaderProp) => {
export const HomeScreenHeader = ({ label, isRootHeader = false, style = [] }: HomeScreenHeaderProp) => {
const insets = useSafeAreaInsets();
const { navigation } = useAppNavigation();
const { user } = useContext(AppContext);
return (
<Row
style={{
justifyContent: isRootHeader ? "space-between" : "flex-start",
alignItems: "center",
paddingHorizontal: isRootHeader ? 24 : 0,
paddingTop: isRootHeader ? 12 : 0,
paddingBottom: 32,
minHeight: 60,
marginTop: insets.top
}}>
style={[
{
justifyContent: isRootHeader ? "space-between" : "flex-start",
alignItems: "center",
paddingHorizontal: isRootHeader ? 24 : 0,
paddingTop: isRootHeader ? 12 : 0,
paddingBottom: 32,
minHeight: 60,
marginTop: insets.top
},
style
]}>
<AppStatusBar style="dark-content" />
{!isRootHeader && (
<Pressable
Expand Down Expand Up @@ -217,6 +219,7 @@ const makeTab = (label: string, icon: (props: { focused: boolean }) => React.Rea
component={screen}
options={({ navigation }) => ({
headerShown,
/* @ts-ignore */
header: () => <HomeScreenHeader label={label} navigation={navigation} isRootHeader={true} />,
tabBarLabel: ({ focused }) => (
<AppText style={[styles.tabLabel, { color: focused ? AppColors.white : AppColorPalettes.blue[400] }]}>{label}</AppText>
Expand Down
16 changes: 6 additions & 10 deletions app/src/components/WheelPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
} from "react-native";
import { StyleSheet } from "react-native";
import { AppText } from "@/components/base/AppText";
import { mod } from "@/util/numbers";
interface Props {
selectedIndex: number;
options: string[];
Expand All @@ -36,11 +37,6 @@ interface Props {
onChange?: (index: number) => void;
}

Number.prototype.mod = function (n) {
"use strict";
return ((this % n) + n) % n;
};

export const WheelPicker: React.FC<Props> = ({
selectedIndex,
options,
Expand All @@ -62,7 +58,7 @@ export const WheelPicker: React.FC<Props> = ({
}) => {
const flatListRef = useRef<FlatList>(null);
if (isInfinite) {
selectedIndex = (selectedIndex + 1).mod(options.length);
selectedIndex = mod(selectedIndex + 1, options.length);
}

const oldVal = useRef(selectedIndex);
Expand Down Expand Up @@ -104,7 +100,7 @@ export const WheelPicker: React.FC<Props> = ({
}

if (isInfinite) {
index = (index - 1).mod(options.length);
index = mod(index - 1, options.length);
}

onChanged(index);
Expand Down Expand Up @@ -133,12 +129,12 @@ export const WheelPicker: React.FC<Props> = ({
index++;
}

index = (index - 1).mod(options.length);
index = mod(index - 1, options.length);

if (index !== oldVal.current && onChange) {
onChange(index);
}
oldVal.current = (index + 1).mod(options.length);
oldVal.current = mod(index + 1, options.length);
};

useEffect(() => {
Expand All @@ -162,7 +158,7 @@ export const WheelPicker: React.FC<Props> = ({
}
}, [selectedIndex]);

const renderItem = useCallback(
const renderItem = useCallback<({ item, index }: { item: any; index: any }) => JSX.Element>(
({ item: option, index }) => (
<WheelPickerItem
key={`option-${index}`}
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/base/AppBottomSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export const AppBottomSheet = React.forwardRef<BottomSheetRefProps, BottomSheetP
//exiting={SlideOutDown}
// entering={SlideInDown}
>
<Animated.View style={[styles.line, handleStyle]} />
<Animated.View style={[styles.horizontalLine, handleStyle]} />
<BottomSheetContext.Provider
value={{
expanded,
Expand Down Expand Up @@ -312,7 +312,7 @@ interface AppBottomSheetScrollRefProps {
}

export const AppBottomSheetFlatList = WithBottomSheetContext(
forwardRef<AppBottomSheetScrollRefProps, FlatListProps<unknown>>((props: FlatListProps<unknown>, ref) => {
forwardRef<AppBottomSheetScrollRefProps, FlatListProps<any>>((props: FlatListProps<any>, ref) => {
const fRef = useRef<FlatList>(null);
useImperativeHandle(ref, () => ({
scrollTo: y => fRef.current?.scrollToOffset({ offset: y, animated: false })
Expand Down Expand Up @@ -342,7 +342,7 @@ const styles = StyleSheet.create({
borderTopLeftRadius: 12,
borderTopRightRadius: 12
},
line: {
horizontalLine: {
width: 52,
height: 4,
backgroundColor: AppColorPalettes.gray[400],
Expand Down
6 changes: 5 additions & 1 deletion app/src/components/base/AppIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import History from "@/assets/icons/history.svg";
import PositionOn from "@/assets/icons/position-on.svg";
import PositionOff from "@/assets/icons/position-off.svg";
import RallyingPoint from "@/assets/icons/liane_rallying_point.svg";
import Seat from "@/assets/icons/seat.svg";

export type IconName = `${(typeof EvaIconsNames)[number]}-outline` | (typeof EvaIconsNames)[number] | CustomIconName;

Expand Down Expand Up @@ -49,6 +50,8 @@ export function AppIcon({ name, color = AppColorPalettes.gray[800], size = AppDi
return <DirectionsWalk {...props} />;
case "rallying-point":
return <RallyingPoint {...props} />;
case "seat":
return <Seat {...props} />;
default:
return <Icon opacity={opacity} name={name} width={size} height={size} fill={color} />;
}
Expand All @@ -67,7 +70,8 @@ const AppIconsNames = [
"position-off",
"twisting-arrow",
"directions-walk",
"rallying-point"
"rallying-point",
"seat"
] as const;

const EvaIconsNames = [
Expand Down
1 change: 1 addition & 0 deletions app/src/components/base/AppIconButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const WithIconButton =
({ backgroundColor, onPress, ...props }: T & AppIconButtonProps) => {
return (
<AppPressableOverlay backgroundStyle={[styles.light, { backgroundColor }]} style={styles.button} onPress={onPress}>
{/* @ts-ignore */}
<WrappedIcon {...props} />
</AppPressableOverlay>
);
Expand Down
Loading

0 comments on commit 983a611

Please sign in to comment.