mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +01:00
added calendar view
This commit is contained in:
parent
785b411889
commit
d436a19116
BIN
src/assets/images/campaign/campaign_day_generic_bg.png
Normal file
BIN
src/assets/images/campaign/campaign_day_generic_bg.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 35 KiB |
BIN
src/assets/images/campaign/campaign_opened.png
Normal file
BIN
src/assets/images/campaign/campaign_opened.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 744 B |
BIN
src/assets/images/campaign/locked.png
Normal file
BIN
src/assets/images/campaign/locked.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 220 B |
BIN
src/assets/images/campaign/unopened.png
Normal file
BIN
src/assets/images/campaign/unopened.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
@ -24,3 +24,4 @@
|
||||
@import './help/HelpView';
|
||||
@import './floorplan-editor/FloorplanEditorView';
|
||||
@import './nitropedia/NitropediaView';
|
||||
@import './campaign/CampaignView';
|
||||
|
1
src/views/campaign/CampaignView.scss
Normal file
1
src/views/campaign/CampaignView.scss
Normal file
@ -0,0 +1 @@
|
||||
@import './views/calendar/CalendarView';
|
60
src/views/campaign/CampaignView.tsx
Normal file
60
src/views/campaign/CampaignView.tsx
Normal file
@ -0,0 +1,60 @@
|
||||
import { CampaignCalendarData, CampaignCalendarDataMessageEvent } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { AddEventLinkTracker, RemoveLinkEventTracker } from '../../api';
|
||||
import { CreateMessageHook } from '../../hooks';
|
||||
import { CalendarView } from './views/calendar/CalendarView';
|
||||
|
||||
export const CampaignView: FC<{}> = props =>
|
||||
{
|
||||
const [ calendarData, setCalendarData ] = useState<CampaignCalendarData>(null);
|
||||
const [ isCalendarOpen, setCalendarOpen ] = useState(false);
|
||||
|
||||
const onCampaignCalendarDataMessageEvent = useCallback((event: CampaignCalendarDataMessageEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
setCalendarData(parser.calendarData);
|
||||
}, []);
|
||||
|
||||
CreateMessageHook(CampaignCalendarDataMessageEvent, onCampaignCalendarDataMessageEvent);
|
||||
|
||||
const onLinkReceived = useCallback((link: string) =>
|
||||
{
|
||||
const value = link.split('/');
|
||||
|
||||
if(value.length < 2) return;
|
||||
|
||||
switch(value[1])
|
||||
{
|
||||
case 'calendar':
|
||||
setCalendarOpen(true);
|
||||
break;
|
||||
}
|
||||
}, []);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
const linkTracker = { linkReceived: onLinkReceived, eventUrlPrefix: 'openView/' };
|
||||
AddEventLinkTracker(linkTracker);
|
||||
|
||||
return () =>
|
||||
{
|
||||
RemoveLinkEventTracker(linkTracker);
|
||||
}
|
||||
}, [onLinkReceived]);
|
||||
|
||||
const onCalendarClose = useCallback(() =>
|
||||
{
|
||||
setCalendarOpen(false);
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<>
|
||||
{(calendarData && isCalendarOpen) &&
|
||||
<CalendarView close={onCalendarClose} campaignName={calendarData.campaignName} currentDay={calendarData.currentDay} numDays={calendarData.campaignDays} openedDays={calendarData.openedDays} missedDays={calendarData.missedDays}/>
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
10
src/views/campaign/views/calendar/CalendarView.scss
Normal file
10
src/views/campaign/views/calendar/CalendarView.scss
Normal file
@ -0,0 +1,10 @@
|
||||
.nitro-campaign-calendar {
|
||||
width: 800px;
|
||||
height: 400px;
|
||||
|
||||
.calendar-day {
|
||||
background: url('../../../../assets/images/campaign/campaign_day_generic_bg.png');
|
||||
max-height: 100%;
|
||||
min-width: 50px;
|
||||
}
|
||||
}
|
43
src/views/campaign/views/calendar/CalendarView.tsx
Normal file
43
src/views/campaign/views/calendar/CalendarView.tsx
Normal file
@ -0,0 +1,43 @@
|
||||
import { FC, useCallback, useState } from 'react';
|
||||
import { LocalizeText } from '../../../../api';
|
||||
import { NitroCardContentView, NitroCardGridItemView, NitroCardGridView, NitroCardHeaderView, NitroCardView } from '../../../../layout';
|
||||
import { CalendarViewProps } from './CalendarView.types';
|
||||
|
||||
export const CalendarView: FC<CalendarViewProps> = props =>
|
||||
{
|
||||
const { close = null, campaignName = null, currentDay = null, numDays = null, missedDays = null, openedDays = null } = props;
|
||||
const [ selectedDay, setSelectedDay ] = useState(currentDay);
|
||||
|
||||
const dayMessage = useCallback((day: number) =>
|
||||
{
|
||||
if(missedDays.includes(day))
|
||||
{
|
||||
return LocalizeText('campaign.calendar.info.expired');
|
||||
}
|
||||
|
||||
if(openedDays.includes(day))
|
||||
{
|
||||
return LocalizeText('campaign.calendar.info.unlocked')
|
||||
}
|
||||
}, [missedDays, openedDays]);
|
||||
|
||||
return (
|
||||
<NitroCardView className="nitro-campaign-calendar">
|
||||
<NitroCardHeaderView headerText={LocalizeText(`campaign.calendar.${campaignName}.title`)} onCloseClick={close}/>
|
||||
<NitroCardContentView>
|
||||
<div className="text-black">
|
||||
<h3>{LocalizeText('campaign.calendar.heading.day', ['number'], [selectedDay.toString()])}</h3>
|
||||
<p>{LocalizeText('')}</p>
|
||||
</div>
|
||||
<NitroCardGridView className="h-100 w-100" columns={7}>
|
||||
{
|
||||
[...Array(7)].map((e, i) =>
|
||||
{
|
||||
return <NitroCardGridItemView key={i} className="calendar-day h-100"/>
|
||||
})
|
||||
}
|
||||
</NitroCardGridView>
|
||||
</NitroCardContentView>
|
||||
</NitroCardView>
|
||||
)
|
||||
}
|
9
src/views/campaign/views/calendar/CalendarView.types.ts
Normal file
9
src/views/campaign/views/calendar/CalendarView.types.ts
Normal file
@ -0,0 +1,9 @@
|
||||
export interface CalendarViewProps
|
||||
{
|
||||
close(): void;
|
||||
campaignName: string;
|
||||
currentDay: number;
|
||||
numDays: number;
|
||||
openedDays: number[];
|
||||
missedDays: number[];
|
||||
}
|
@ -6,6 +6,7 @@ import { TransitionAnimation, TransitionAnimationTypes } from '../../layout';
|
||||
import { AchievementsView } from '../achievements/AchievementsView';
|
||||
import { AvatarEditorView } from '../avatar-editor/AvatarEditorView';
|
||||
import { CameraWidgetView } from '../camera/CameraWidgetView';
|
||||
import { CampaignView } from '../campaign/CampaignView';
|
||||
import { CatalogView } from '../catalog/CatalogView';
|
||||
import { ChatHistoryView } from '../chat-history/ChatHistoryView';
|
||||
import { FloorplanEditorView } from '../floorplan-editor/FloorplanEditorView';
|
||||
@ -77,6 +78,7 @@ export const MainView: FC<MainViewProps> = props =>
|
||||
<HelpView />
|
||||
<FloorplanEditorView />
|
||||
<NitropediaView />
|
||||
<CampaignView />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user