Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 5cee436e

Přidáno uživatelem Fantič před více než 1 rok

re #10871: PlanViewPage: fullScreenMode

Zobrazit rozdíly:

src/pages/PlanViewPage.tsx
52 52
  const floorMapImage = useSelector((state: RootState) => state.planViewState.mapImage)
53 53
  const floorMapImageLoading = useSelector((state: RootState) => state.planViewState.mapImageLoading)
54 54

  
55
  // todo
56
  const castlePlanFullScreenMode = false
57

  
55 58
  const toast = useToast();
56 59

  
57 60
  useEffect(() => {
......
178 181
  }
179 182

  
180 183
  return (
181
    <Center m={2} mr={0} mb={6} flex={1}>
182

  
183
      <ScrollView flex={1} w={"100%"} nestedScrollEnabled={!isInteractingWithCastlePlan}>
184
        <VStack space={1} mr={4}>
185

  
186
          {/* Selection */}
187

  
188
          {
189
            floorListLoading ?
190
              <LoadingBox text="Floor list loading"></LoadingBox>
191
              :
192
              <>
193
                {/* Floor */}
194
                <Select
195
                  mt={2.5}
196
                  ml={2.5}
197
                  mr={2.5}
198

  
199
                  placeholder={"Floor"}
200
                  selectedValue={selectedFloor?.id}
201
                  onValueChange={selectFloor}
202
                  variant="rounded"
203
                >
204
                  {floorList.map((floor, index) => {
205
                    return (
206
                      <Select.Item value={floor.id} label={floor.label} />
207
                    );
208
                  })}
209
                </Select>
210

  
211
                {/* Room */}
212
                {selectedFloor && selectedFloor.roomList && selectedFloor.roomList.length > 0 &&
213
                  < Select
214
                    mt={2.5}
215
                    ml={2.5}
216
                    mr={2.5}
217

  
218
                    placeholder={"Room"}
219
                    selectedValue={selectedRoom?.id.toString()}
220
                    onValueChange={(value: string) => selectRoom(parseInt(value))}
221
                    variant="rounded"
222
                  >
223
                    {selectedFloor?.roomList?.map((room, index) => {
224
                      if (room.room_list) {
225
                        return (
226
                          <Select.Item value={room.id.toString()} label={room.label} />
227
                        );
228
                      }
229
                    })}
230
                  </Select>
231
                }
232

  
233
                {/* Place */}
234
                {selectedRoom && selectedRoom.places && selectedRoom.places.length > 0 &&
184
    <Box flex={1}>
185
      {!castlePlanFullScreenMode ? (
186
        <ScrollView flex={1} w={"100%"} nestedScrollEnabled={!isInteractingWithCastlePlan}>
187
          <VStack space={1} mr={4}>
188

  
189
            {/* Selection */}
190

  
191
            {
192
              floorListLoading ?
193
                <LoadingBox text="Floor list loading"></LoadingBox>
194
                :
195
                <>
196
                  {/* Floor */}
235 197
                  <Select
236 198
                    mt={2.5}
237 199
                    ml={2.5}
238 200
                    mr={2.5}
239 201

  
240
                    placeholder={"Place"}
241
                    selectedValue={selectedPlace?.id.toString()}
242
                    onValueChange={(value: string) => selectPlace(parseInt(value))}
202
                    placeholder={"Floor"}
203
                    selectedValue={selectedFloor?.id}
204
                    onValueChange={selectFloor}
243 205
                    variant="rounded"
244 206
                  >
245
                    {selectedRoom?.places?.map((place, index) => {
207
                    {floorList.map((floor, index) => {
246 208
                      return (
247
                        <Select.Item value={place.id.toString()} label={place.label} />
209
                        <Select.Item value={floor.id} label={floor.label} />
248 210
                      );
249 211
                    })}
250 212
                  </Select>
251
                }
252

  
253
                {/* Filter */}
254
                <Flex direction="row" alignItems="center" justify="flex-end"
255
                  mt={2.5}
256
                  ml={2.5}
257
                  mr={3}
258
                >
259
                  <Button
260
                    endIcon={
261
                      <CloseIcon size="xs" />
262
                    }
263
                    onPress={clearForm}
264
                    variant="outline"
265
                    color="primary.500"
266
                    borderColor="primary.100"
267
                    mr={2}
268
                    borderRadius={15}
269
                    size={"md"}
270
                  >
271
                    Reset
272
                  </Button>
273
                  <Button
274
                    onPress={() => {
275
                      if (selectedRoom && !selectedPlace) {
276
                        searchSubmit(selectedRoom.id)
277
                      }
278
                      else if (selectedRoom && selectedPlace) {
279
                        searchSubmit(selectedRoom.id, selectedPlace.id)
280
                      }
281 213

  
282
                    }}
283
                    colorScheme="primary"
284
                    background={"primary.100"}
285
                    variant="solid"
286
                    borderRadius={15}
287
                    size={"md"}
288
                  >
289
                    Search
290
                  </Button>
291
                </Flex>
292
              </>
293
          }
294

  
295
          {/* Plan */}
296
          {/* temporary prototype */}
297

  
298
          {selectedFloor && !floorListLoading && (
299
            floorMapImageLoading ?
300
              <LoadingBox text="Loading castle plan" />
301
              :
302
              floorMapImage &&
303
              <Box mt={2.5} ml={2.5}
304
                onTouchStart={() => setIsInteractingWithCastlePlan(true)}
305
                onTouchEnd={() => setIsInteractingWithCastlePlan(true)}>
306
                <CastlePlanView mapImage={floorMapImage} selectedRoom={selectedRoom} roomList={selectedFloor.roomList} />
307
              </Box>
308
          )
309
          }
310

  
311
          {/* Item List */}
312
          <>
313
            {inventoriesLoading ?
314
              <LoadingBox text="Loading available inventories..." />
315
              :
316
              <Box mt={2.5} ml={2.5}>
317
                <ListView
318

  
319
                  navigation={navigation}
320
                  hideHeaderText
321

  
322
                  inventories={inventories}
323
                  numOfResults={numberOfResults}
324

  
325
                  data={data}
326
                  loadedPages={pagination ?? {}}
327
                  inventoriesDataLoading={dataLoading ?? {}}
328
                  handleLoadMoreItems={(inventoryName: string, cursor: number) => {
329
                    dispatch(getPlanItems({ cursor: cursor, inventory: inventoryName, room: selectedRoom?.id ?? 0, place: selectedPlace?.id }))
214
                  {/* Room */}
215
                  {selectedFloor && selectedFloor.roomList && selectedFloor.roomList.length > 0 &&
216
                    < Select
217
                      mt={2.5}
218
                      ml={2.5}
219
                      mr={2.5}
220

  
221
                      placeholder={"Room"}
222
                      selectedValue={selectedRoom?.id.toString()}
223
                      onValueChange={(value: string) => selectRoom(parseInt(value))}
224
                      variant="rounded"
225
                    >
226
                      {selectedFloor?.roomList?.map((room, index) => {
227
                        if (room.room_list) {
228
                          return (
229
                            <Select.Item value={room.id.toString()} label={room.label} />
230
                          );
231
                        }
232
                      })}
233
                    </Select>
330 234
                  }
235

  
236
                  {/* Place */}
237
                  {selectedRoom && selectedRoom.places && selectedRoom.places.length > 0 &&
238
                    <Select
239
                      mt={2.5}
240
                      ml={2.5}
241
                      mr={2.5}
242

  
243
                      placeholder={"Place"}
244
                      selectedValue={selectedPlace?.id.toString()}
245
                      onValueChange={(value: string) => selectPlace(parseInt(value))}
246
                      variant="rounded"
247
                    >
248
                      {selectedRoom?.places?.map((place, index) => {
249
                        return (
250
                          <Select.Item value={place.id.toString()} label={place.label} />
251
                        );
252
                      })}
253
                    </Select>
331 254
                  }
332
                />
333
              </Box>
334
            }
335
          </>
336 255

  
337
        </VStack>
338
      </ScrollView>
339
    </Center>
256
                  {/* Filter */}
257
                  <Flex direction="row" alignItems="center" justify="flex-end"
258
                    mt={2.5}
259
                    ml={2.5}
260
                    mr={3}
261
                  >
262
                    <Button
263
                      endIcon={
264
                        <CloseIcon size="xs" />
265
                      }
266
                      onPress={clearForm}
267
                      variant="outline"
268
                      color="primary.500"
269
                      borderColor="primary.100"
270
                      mr={2}
271
                      borderRadius={15}
272
                      size={"md"}
273
                    >
274
                      Reset
275
                    </Button>
276
                    <Button
277
                      onPress={() => {
278
                        if (selectedRoom && !selectedPlace) {
279
                          searchSubmit(selectedRoom.id)
280
                        }
281
                        else if (selectedRoom && selectedPlace) {
282
                          searchSubmit(selectedRoom.id, selectedPlace.id)
283
                        }
284

  
285
                      }}
286
                      colorScheme="primary"
287
                      background={"primary.100"}
288
                      variant="solid"
289
                      borderRadius={15}
290
                      size={"md"}
291
                    >
292
                      Search
293
                    </Button>
294
                  </Flex>
295
                </>
296
            }
340 297

  
298
            {/* Plan */}
299
            {/* temporary prototype */}
300

  
301
            {selectedFloor && !floorListLoading && (
302
              floorMapImageLoading ?
303
                <LoadingBox text="Loading castle plan" />
304
                :
305
                floorMapImage &&
306
                <Box mt={2.5} ml={2.5}
307
                  onTouchStart={() => setIsInteractingWithCastlePlan(true)}
308
                  onTouchEnd={() => setIsInteractingWithCastlePlan(true)}>
309
                  <CastlePlanView mapImage={floorMapImage} selectedRoom={selectedRoom} roomList={selectedFloor.roomList} />
310
                </Box>
311
            )
312
            }
341 313

  
314
            {/* Item List */}
315
            <>
316
              {inventoriesLoading ?
317
                <LoadingBox text="Loading available inventories..." />
318
                :
319
                <Box mt={2.5} ml={2.5}>
320
                  <ListView
321

  
322
                    navigation={navigation}
323
                    hideHeaderText
324

  
325
                    inventories={inventories}
326
                    numOfResults={numberOfResults}
327

  
328
                    data={data}
329
                    loadedPages={pagination ?? {}}
330
                    inventoriesDataLoading={dataLoading ?? {}}
331
                    handleLoadMoreItems={(inventoryName: string, cursor: number) => {
332
                      dispatch(getPlanItems({ cursor: cursor, inventory: inventoryName, room: selectedRoom?.id ?? 0, place: selectedPlace?.id }))
333
                    }
334
                    }
335
                  />
336
                </Box>
337
              }
338
            </>
339

  
340
          </VStack>
341
        </ScrollView>)
342
        :
343
        floorMapImageLoading ?
344
          <LoadingBox text="Loading castle plan" />
345
          :
346
          floorMapImage && selectedFloor && 
347
          <Box>
348
            <CastlePlanView fullScreenMode mapImage={floorMapImage} selectedRoom={selectedRoom} roomList={selectedFloor.roomList} />
349
          </Box>
350
      }
351
    </Box>
342 352
  );
343 353
}
344 354

  

Také k dispozici: Unified diff