be-components 4.7.3 → 4.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,12 +13,13 @@ import { Button, Text, View } from '../../Components/Themed';
13
13
  type EngageHeaderProps = {
14
14
  companies:CompanyProps[],
15
15
  width:number,
16
+ view_mode?:'desktop'|'mobile',
16
17
  onEvent?:(be_event:BEEventProps) => void,
17
18
  onSelectCompany?:(company:CompanyProps) => void,
18
19
  onManage?:() => void
19
20
  }
20
21
 
21
- const EngageHeader = ({ companies, width, onManage, onEvent, onSelectCompany }:EngageHeaderProps) => {
22
+ const EngageHeader = ({ companies, width, view_mode, onManage, onEvent, onSelectCompany }:EngageHeaderProps) => {
22
23
  const [ active_company, setActiveComany ] = useState<number>(0);
23
24
  const [ search, setSearch ] = useState<{
24
25
  loading:boolean,
@@ -80,27 +81,25 @@ const EngageHeader = ({ companies, width, onManage, onEvent, onSelectCompany }:E
80
81
  return (
81
82
  <View type = 'header'>
82
83
  <LinearGradient colors={[Colors.views.background, Colors.views.header ]} style={{ padding:20, flexDirection:'row', alignItems:'center' }}>
83
- <View float style={{ borderRadius:100, height:75, width:75, backgroundColor:Colors.text.white, justifyContent:'center', alignItems:'center', ...view_styles.float }}>
84
+ <View float style={{ borderRadius:100, width:view_mode == 'desktop' ? 75: 50, height:view_mode == 'desktop' ? 75: 50, justifyContent:'center', alignItems:'center', ...view_styles.float }}>
84
85
  {company ?
85
86
  <Image
86
87
  source={{ uri: company.company_image?.url }}
87
- style={{ height:50, width:50 }}
88
+ style={{ height:view_mode=='desktop'?50:30, width:view_mode=='desktop'?50:30 }}
88
89
  resizeMode='cover'
89
90
  />
90
91
  :<></>}
91
92
  </View>
92
93
  <View transparent style={{ flex:1, marginLeft:20 }}>
93
- <Text size={20} weight='bold' color={Colors.text.h1}>Engage with our partners</Text>
94
- <Text style={{ marginTop:10 }} size={14} weight='regular' color={Colors.text.h1}>Competitions, squares, brackets are all brought to you without fees thanks to our amazing partners.</Text>
94
+ <Text theme='h1' color={Colors.text.h1}>Engage with our partners</Text>
95
+ <Text style={{ marginTop:5 }} size={14} theme='description'>Competitions, squares, brackets are all brought to you without fees thanks to our amazing partners.</Text>
95
96
  </View>
96
- {onManage ?
97
- <View style={{ position:'absolute', bottom:5, right:10 }}>
97
+ {onManage && view_mode == 'desktop' ?
98
98
  <Button
99
- title='MANAGE'
99
+ title='Manage'
100
100
  type='success'
101
101
  onPress={() => onManage()}
102
102
  />
103
- </View>
104
103
  :<></>}
105
104
  </LinearGradient>
106
105
  <View transparent style={{ padding:10 }}>
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { ActivityIndicator, FlatList, KeyboardAvoidingView, Modal, Platform } from 'react-native';
2
+ import { ActivityIndicator, FlatList, Image, KeyboardAvoidingView, Modal, Platform } from 'react-native';
3
3
  import type { BEEventProps, BracketCompetitionProps, BracketProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, EventProps, FocusPositionProps, LeagueProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
4
4
  import { EngageApi, EngageHelpers } from './api';
5
5
  import CompetitionCard from './components/CompetitionCard';
@@ -18,9 +18,11 @@ import { useColors } from '../constants/useColors';
18
18
  type EngageModuleProps = {
19
19
  player_id?:string,
20
20
  insets?: { top:number, bottom:number },
21
+ view_mode?:'desktop'|'mobile'
21
22
  onEvent?:(be_event:BEEventProps) => void,
22
23
  onFocusPosition?:(pos:FocusPositionProps) => void,
23
- onManage:() => void,
24
+ onManage?:() => void,
25
+ onBracketRoom?:() => void,
24
26
  onCreateSeason?:() => void,
25
27
  onSelectCompany?:(c:CompanyProps) => void,
26
28
  onCreateCompetition?:() => void,
@@ -34,7 +36,7 @@ type EngageModuleProps = {
34
36
 
35
37
  const engage_sections = ['header','toggle', 'private','engagements']
36
38
 
37
- const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition, onSelectSquaresCompetition, onSelectCompetitionSeason,
39
+ const EngageModule = ({ view_mode, insets, onBracketRoom, onSelectBracketCompetition, onSelectCompetition, onSelectSquaresCompetition, onSelectCompetitionSeason,
38
40
  onCreateSeason, onCreateCompetition, onCreateBracketCompetition, onCreateSquares, onFocusPosition, onManage, onEvent, onSelectCompany
39
41
  }:EngageModuleProps) => {
40
42
  const [ module_size, setModuleSize ] = useState({ width:0, height:0 });
@@ -45,7 +47,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
45
47
  }>({
46
48
  connected: false
47
49
  });
48
- const [ active_tab, setActiveTab ] = useState('competitions');
50
+ const [ active_tab, setActiveTab ] = useState('brackets');
49
51
  const [ module_data, setModuleData ] = useState<{
50
52
  loading:boolean,
51
53
  competitions:CompetitionProps[],
@@ -53,6 +55,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
53
55
  competition_types:CompetitionTypeProps[],
54
56
  competition_result_types:CompetitionResultTypeProps[],
55
57
  competition_payouts:CompetitionPayoutTypeProps[],
58
+ selected_bracket?:BracketProps,
56
59
  events:EventProps[],
57
60
  leagues:LeagueProps[],
58
61
  brackets:BracketProps[],
@@ -75,10 +78,14 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
75
78
  bracket_competitions:[],
76
79
  players:[]
77
80
  });
78
- const { loading, competitions, competition_seasons, competition_result_types, squares_competitions, brackets, leagues, bracket_competitions, events, competition_types, companies, players } = module_data;
79
-
81
+ const { loading, competitions, selected_bracket, competition_seasons, competition_result_types, squares_competitions, brackets, leagues, bracket_competitions, events, competition_types, companies, players } = module_data;
80
82
  const Colors = useColors();
81
-
83
+ const available_brackets = brackets.filter(b => bracket_competitions.map(bc => bc.bracket_id).includes(b.bracket_id))
84
+ let visible_bracket_competitions = [ ...bracket_competitions ]
85
+ if(selected_bracket){
86
+ visible_bracket_competitions = visible_bracket_competitions.filter(bc => bc.bracket_id == selected_bracket.bracket_id);
87
+ }
88
+ const engagement_width = view_mode == 'mobile' ? module_size.width - 20 : (module_size.width / 3) - 20
82
89
  useEffect(() => {
83
90
  EngageApi.setEnvironment();
84
91
  getDataFromServer()
@@ -135,7 +142,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
135
142
  const company = companies.find(c => c.company_id == data.item.company_id);
136
143
  const event = events.find(e => e.event_id == data.item.event_id)
137
144
  return (
138
- <View transparent style={{ margin:10 }}>
145
+ <View key={data.item.sq_comp_id.toString()} transparent style={{ margin:10, width: engagement_width }}>
139
146
  <SquaresCompetitionCard
140
147
  squares_competition={data.item}
141
148
  company={company}
@@ -156,7 +163,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
156
163
  const league = leagues.find(e => e.league_id == bracket?.league_id)
157
164
  if(!competition_result_type){ return <></> }
158
165
  return (
159
- <View transparent style={{ margin:10 }}>
166
+ <View key={data.item.bracket_competition_id.toString()} transparent style={{ margin:10, width: engagement_width }}>
160
167
  <BracketCompetitionCard
161
168
  bracket_competition={data.item}
162
169
  company={company}
@@ -182,6 +189,28 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
182
189
  )
183
190
  }
184
191
 
192
+ const renderBrackets = (data: { item:BracketProps, index:number }) => {
193
+ const selected = selected_bracket?.bracket_id == data.item.bracket_id ? true : false
194
+ const league = leagues.find(l => l.league_id == data.item.league_id);
195
+ return (
196
+ <Button
197
+ float
198
+ type={selected ? 'action' : 'text'}
199
+ style={{ padding:10, flexDirection:'row', alignItems:'center', margin:4, borderRadius:100 }}
200
+ onPress={() => selected ? setModuleData({ ...module_data, selected_bracket: undefined }): setModuleData({ ...module_data, selected_bracket:data.item })}
201
+ >
202
+ {league ?
203
+ <Image
204
+ source={{ uri: league.league_image }}
205
+ style={{ height:25, width:25, marginRight:10 }}
206
+ resizeMode='cover'
207
+ />
208
+ :<></>}
209
+ <Text style={{ maxWidth:150 }} textAlign='center' theme='h2' color={selected?Colors.text.white : Colors.text.h1}>{data.item.bracket_name}</Text>
210
+ </Button>
211
+ )
212
+ }
213
+
185
214
  const renderCompetitions = (data: { item:CompetitionProps, index:number }) => {
186
215
  const admin = players.find(p => p.player_id == data.item.admin_id);
187
216
  const pacer = players.find(p => p.player_id == data.item.pacer_id);
@@ -190,7 +219,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
190
219
  const competition_result_type = competition_result_types.find(t => t.competition_result_type_id == data.item.competition_result_type_id);
191
220
  if(!competition_type || !competition_result_type){ return <></> }
192
221
  return (
193
- <View transparent style={{ margin:10 }}>
222
+ <View key={data.item.competition_id.toString()} transparent style={{ margin:10, width:engagement_width }}>
194
223
  <CompetitionCard
195
224
  competition={data.item}
196
225
  company={company}
@@ -211,6 +240,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
211
240
  <EngageHeader
212
241
  companies={companies}
213
242
  width={module_size.width}
243
+ view_mode={view_mode}
214
244
  onManage={onManage}
215
245
  onEvent={onEvent}
216
246
  onSelectCompany={onSelectCompany}
@@ -218,7 +248,15 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
218
248
  )
219
249
  case 'toggle':
220
250
  return (
221
- <View float style={{ margin:10 }}>
251
+ <View transparent style={{ margin:10 }}>
252
+ {onManage && view_mode == 'mobile' ?
253
+ <Button
254
+ title='Manage competitions you have created'
255
+ style={{ paddingRight:20, alignSelf:'flex-end' }}
256
+ type='text'
257
+ onPress={() => onManage()}
258
+ />
259
+ :<></>}
222
260
  <Toggle
223
261
  background_color={Colors.views.header}
224
262
  inactive_title_color={Colors.text.h1}
@@ -290,11 +328,12 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
290
328
  :<></>}
291
329
 
292
330
  </View>
293
- <FlatList
294
- data={competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
295
- renderItem={renderCompetitions}
296
- keyExtractor={(item) => item.competition_id.toString()}
297
- />
331
+ <View style={{ flexDirection:'row', flexWrap:'wrap', justifyContent:'center' }}>
332
+ {competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix()).map((c, i) => {
333
+ return renderCompetitions({ item: c, index: i })
334
+ })}
335
+ </View>
336
+
298
337
  </View>
299
338
  </View>
300
339
  :active_tab == 'squares' ?
@@ -314,15 +353,30 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
314
353
  :<></>}
315
354
  </View>
316
355
  </View>
317
- <FlatList
318
- data={squares_competitions.sort((a,b) => moment(a.begin_datetime).unix() - moment(b.begin_datetime).unix())}
319
- renderItem={renderSquaresCompetitions}
320
- keyExtractor={(item) => item.sq_comp_id.toString()}
321
- />
356
+ <View style={{ flexDirection:'row', flexWrap:'wrap', justifyContent:'center' }}>
357
+
358
+ {squares_competitions.sort((a,b) => moment(a.begin_datetime).unix() - moment(b.begin_datetime).unix()).map((c, i) => {
359
+ return renderSquaresCompetitions({ item: c, index: i })
360
+ })}
361
+ </View>
322
362
  </View>
323
363
  :active_tab == 'brackets' ?
324
364
  <View transparent>
325
- <View transparent style={{ marginBottom:15, marginTop:10 }}>
365
+ <View transparent>
366
+ {view_mode == 'mobile' && onBracketRoom ?
367
+ <View float style={{ flexDirection:'row', alignItems:'center', margin:4, padding:10, marginBottom:10 }}>
368
+ <View style={{ flex:1, marginRight:10 }}>
369
+ <Text theme='h1'>Bracket Home</Text>
370
+ <Text theme='description'>Go to bracket room to manage all your brackets and find new ones to complete.</Text>
371
+ </View>
372
+ <Button
373
+ type='action'
374
+ title='Bracket Room'
375
+ onPress={() => onBracketRoom()}
376
+ />
377
+ </View>
378
+
379
+ :<></>}
326
380
  <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
327
381
  <View transparent style={{ flex:1 }}>
328
382
  <Text theme='h1'>Public Bracket Competitions</Text>
@@ -335,13 +389,29 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
335
389
  onPress={() => onCreateBracketCompetition()}
336
390
  />
337
391
  :<></>}
392
+ {view_mode == 'desktop' && onBracketRoom ?
393
+ <Button
394
+ type='action'
395
+ title='Bracket Room'
396
+ onPress={() => onBracketRoom()}
397
+ />
398
+ :<></>}
399
+ </View>
400
+ </View>
401
+ <View style={{ marginTop:10 }}>
402
+ <FlatList
403
+ data={available_brackets}
404
+ key={'bracket_list'}
405
+ horizontal
406
+ renderItem={renderBrackets}
407
+ keyExtractor={(item) => item.bracket_id.toString()}
408
+ />
409
+ <View style={{ flexDirection:'row', flexWrap:'wrap', justifyContent:'center' }}>
410
+ {visible_bracket_competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix()).map((c, i) => {
411
+ return renderBracketCompetitions({ item: c, index: i })
412
+ })}
338
413
  </View>
339
414
  </View>
340
- <FlatList
341
- data={bracket_competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
342
- renderItem={renderBracketCompetitions}
343
- keyExtractor={(item) => item.bracket_competition_id.toString()}
344
- />
345
415
  </View>
346
416
  :<></>}
347
417
  </View>
@@ -367,14 +437,15 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
367
437
  {show_code_prompt ?
368
438
  <Modal
369
439
  transparent
370
- animationType='slide'
440
+ animationType={view_mode == 'desktop' ? 'fade': 'slide'}
371
441
  style={{ flex:1 }}
372
442
  >
373
443
  <KeyboardAvoidingView
374
444
  style={{ flex:1 }}
375
445
  behavior={Platform.OS == 'ios' ? 'padding' : 'height'}
376
446
  >
377
- <View type='blur' style={{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom }}>
447
+ <View type='blur' style={view_mode == 'desktop'?{ flex:1, justifyContent:'center', alignItems:'center' }:{ flex:1, justifyContent:'flex-end', paddingBottom:insets?.bottom }}>
448
+ <View transparent style={view_mode=='desktop'?{ width:500 }: {}}>
378
449
  <PrivateCodePrompt
379
450
  onFocusPosition={onFocusPosition}
380
451
  onFoundBracket={(b) => {
@@ -396,6 +467,7 @@ const EngageModule = ({ insets, onSelectBracketCompetition, onSelectCompetition,
396
467
  }}
397
468
  onClose={() => setShowCodePrompt(false)}
398
469
  />
470
+ </View>
399
471
  </View>
400
472
  </KeyboardAvoidingView>
401
473
  </Modal>