Skip to content

Commit

Permalink
fix: Dealer search and feedback stuff
Browse files Browse the repository at this point in the history
* Tab label added to control how tab navigator stuff is displayed.
* Viewers initial zoom changed, fixed share debounce.
* Fuse integration increase limit.
* Dealer and event share debounced.
* Dealer and event router new tab label used.
* Fixed search issue where an old property name was used.
  • Loading branch information
lukashaertel committed Sep 14, 2024
1 parent cec9e45 commit 4e4b234
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 10 deletions.
33 changes: 33 additions & 0 deletions src/components/generic/atoms/TabLabel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { StyleSheet } from "react-native";
import { Label } from "./Label";

export const tabLabelMaxWidth = 110;

export type TabLabelProps = {
focused: boolean;
children: string;
wide: boolean;
};

export const TabLabel = ({ focused, children, wide }: TabLabelProps) => {
return (
<Label type="bold" style={[focused ? styles.focused : styles.unfocused, wide && styles.wide]} numberOfLines={1} ellipsizeMode="tail">
{children}
</Label>
);
};

const styles = StyleSheet.create({
wide: {
maxWidth: tabLabelMaxWidth,
paddingHorizontal: 5,
},
unfocused: {
maxWidth: tabLabelMaxWidth,
opacity: 0.5,
},
focused: {
maxWidth: tabLabelMaxWidth,
opacity: 1,
},
});
4 changes: 2 additions & 2 deletions src/components/viewer/ViewerImageRecord.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Image } from "../generic/atoms/Image";
import { Header } from "../generic/containers/Header";
import { minZoomFor, shareImage } from "./Viewer.common";

const viewerPadding = 40;
const viewerPadding = 20;

export type ViewerImageRecordProps = {
id: RecordId;
Expand Down Expand Up @@ -42,7 +42,7 @@ export const ViewerImageRecord: FC<ViewerImageRecordProps> = ({ id }) => {
contentHeight={image.Height + viewerPadding * 2}
minZoom={minZoom}
maxZoom={maxZoom}
initialZoom={minZoom}
initialZoom={minZoom * 1.2}
bindToBorders={true}
>
<View style={styleContainer}>
Expand Down
7 changes: 2 additions & 5 deletions src/components/viewer/ViewerUrl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Image } from "../generic/atoms/Image";
import { Header } from "../generic/containers/Header";
import { minZoomFor, shareImage } from "./Viewer.common";

const viewerPadding = 40;
const viewerPadding = 20;

export type ViewerUrlProps = {
url: string;
Expand All @@ -24,13 +24,11 @@ export const ViewerUrl: FC<ViewerUrlProps> = ({ url, title }) => {
ReactImage.getSize(
url,
(width, height) => {
console.log("GOT SIZE", width, height);
// Gotten successfully.
setWidth(width);
setHeight(height);
},
() => {
console.log("SIZE FAIL");
// Failed, set to 0 so that expo image starts loading.
setWidth(0);
setHeight(0);
Expand All @@ -57,7 +55,7 @@ export const ViewerUrl: FC<ViewerUrlProps> = ({ url, title }) => {
contentHeight={height + viewerPadding * 2}
minZoom={minZoom}
maxZoom={maxZoom}
initialZoom={minZoom}
initialZoom={minZoom * 1.2}
bindToBorders={true}
>
<View style={{ width, height }}>
Expand All @@ -68,7 +66,6 @@ export const ViewerUrl: FC<ViewerUrlProps> = ({ url, title }) => {
source={url}
priority="high"
onLoad={(event) => {
console.log("EXPO GOT SIZE", event.source.width, event.source.height);
setWidth(event.source.width);
setHeight(event.source.height);
}}
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/searching/useFuseIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RootState, useAppSelector } from "../../store";
* @param selector The selector from the app state.
* @param limit Maximum results.
*/
export const useFuseIntegration = <T extends object>(selector: (state: RootState) => Fuse<T>, limit = 30): [string, Dispatch<SetStateAction<string>>, T[] | null] => {
export const useFuseIntegration = <T extends object>(selector: (state: RootState) => Fuse<T>, limit = 100): [string, Dispatch<SetStateAction<string>>, T[] | null] => {
// Search state.
const fuse = useAppSelector(selector);
const [filter, setFilter] = useState("");
Expand Down
14 changes: 13 additions & 1 deletion src/routes/dealers/DealersRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Icon } from "../../components/generic/atoms/Icon";
import { useTabStyles } from "../../components/generic/nav/useTabStyles";
import { AreasRouterParamsList } from "../AreasRouter";
import { IndexRouterParamsList } from "../IndexRouter";
import { TabLabel } from "../../components/generic/atoms/TabLabel";
import { DealersAd, DealersAdParams } from "./DealersAd";
import { DealersAll, DealersAllParams } from "./DealersAll";
import { DealersAlpha, DealersAlphaParams } from "./DealersAlpha";
Expand Down Expand Up @@ -88,7 +89,18 @@ export const DealersRouter: FC<DealersRouterProps> = () => {
// If the screens require too much performance we should set detach to true again.
return (
<View style={StyleSheet.absoluteFill}>
<Tab.Navigator initialRouteName="All" initialLayout={layout} sceneContainerStyle={scene}>
<Tab.Navigator
initialRouteName="All"
initialLayout={layout}
sceneContainerStyle={scene}
screenOptions={{
tabBarLabel: ({ focused, children }) => (
<TabLabel wide={false} focused={focused}>
{children}
</TabLabel>
),
}}
>
{defaultScreens}
</Tab.Navigator>
</View>
Expand Down
6 changes: 6 additions & 0 deletions src/routes/events/EventsRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { EventDayRecord } from "../../store/eurofurence/types";
import { AreasRouterParamsList } from "../AreasRouter";
import { IndexRouterParamsList } from "../IndexRouter";
import { conTimeZone } from "../../configuration";
import { TabLabel } from "../../components/generic/atoms/TabLabel";
import { PersonalSchedule, PersonalScheduleParams } from "./PersonalSchedule";
import { EventsSearch, EventsSearchParams } from "./EventsSearch";
import { EventsRouterContextProvider, useEventsRouterContext } from "./EventsRouterContext";
Expand Down Expand Up @@ -196,6 +197,11 @@ const EventsRouterContent: FC<EventsRouterProps> = ({ route }) => {
screenOptions={{
tabBarScrollEnabled: scroll,
tabBarItemStyle: scroll ? { width: 110 } : undefined,
tabBarLabel: ({ focused, children }) => (
<TabLabel wide={scroll} focused={focused}>
{children}
</TabLabel>
),
lazy: true,
lazyPreloadDistance: 3,
}}
Expand Down
2 changes: 1 addition & 1 deletion src/store/eurofurence/selectors/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const searchOptions: IFuseOptions<any> = {
*/
const dealerSearchProperties: FuseOptionKey<DealerDetails>[] = [
{
name: "FullName",
name: "DisplayNameOrAttendeeNickname",
weight: 2,
},
{
Expand Down

0 comments on commit 4e4b234

Please sign in to comment.