be-components 4.2.0 → 4.2.1

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.
Files changed (102) hide show
  1. package/lib/commonjs/Poll/components/CampaignHeader.js +20 -15
  2. package/lib/commonjs/Poll/components/CampaignHeader.js.map +1 -1
  3. package/lib/commonjs/Poll/components/CampaignLeaderboard.js +77 -75
  4. package/lib/commonjs/Poll/components/CampaignLeaderboard.js.map +1 -1
  5. package/lib/commonjs/Poll/components/CampaignProgressBar.js +21 -20
  6. package/lib/commonjs/Poll/components/CampaignProgressBar.js.map +1 -1
  7. package/lib/commonjs/Poll/components/CampaignResult.js +21 -19
  8. package/lib/commonjs/Poll/components/CampaignResult.js.map +1 -1
  9. package/lib/commonjs/Poll/components/PollCard.js +240 -218
  10. package/lib/commonjs/Poll/components/PollCard.js.map +1 -1
  11. package/lib/commonjs/Poll/components/PollOptionCard.js +28 -25
  12. package/lib/commonjs/Poll/components/PollOptionCard.js.map +1 -1
  13. package/lib/commonjs/Poll/components/PollQuestionsSection.js +25 -19
  14. package/lib/commonjs/Poll/components/PollQuestionsSection.js.map +1 -1
  15. package/lib/commonjs/Poll/components/PollSelectCard.js +48 -45
  16. package/lib/commonjs/Poll/components/PollSelectCard.js.map +1 -1
  17. package/lib/commonjs/Poll/index.js +97 -93
  18. package/lib/commonjs/Poll/index.js.map +1 -1
  19. package/lib/module/Poll/components/CampaignHeader.js +19 -14
  20. package/lib/module/Poll/components/CampaignHeader.js.map +1 -1
  21. package/lib/module/Poll/components/CampaignLeaderboard.js +59 -57
  22. package/lib/module/Poll/components/CampaignLeaderboard.js.map +1 -1
  23. package/lib/module/Poll/components/CampaignProgressBar.js +17 -15
  24. package/lib/module/Poll/components/CampaignProgressBar.js.map +1 -1
  25. package/lib/module/Poll/components/CampaignResult.js +17 -15
  26. package/lib/module/Poll/components/CampaignResult.js.map +1 -1
  27. package/lib/module/Poll/components/PollCard.js +238 -216
  28. package/lib/module/Poll/components/PollCard.js.map +1 -1
  29. package/lib/module/Poll/components/PollOptionCard.js +24 -20
  30. package/lib/module/Poll/components/PollOptionCard.js.map +1 -1
  31. package/lib/module/Poll/components/PollQuestionsSection.js +21 -15
  32. package/lib/module/Poll/components/PollQuestionsSection.js.map +1 -1
  33. package/lib/module/Poll/components/PollSelectCard.js +33 -30
  34. package/lib/module/Poll/components/PollSelectCard.js.map +1 -1
  35. package/lib/module/Poll/index.js +97 -92
  36. package/lib/module/Poll/index.js.map +1 -1
  37. package/lib/typescript/lib/commonjs/Poll/components/CampaignHeader.d.ts.map +1 -1
  38. package/lib/typescript/lib/commonjs/Poll/components/CampaignLeaderboard.d.ts +1 -2
  39. package/lib/typescript/lib/commonjs/Poll/components/CampaignLeaderboard.d.ts.map +1 -1
  40. package/lib/typescript/lib/commonjs/Poll/components/CampaignProgressBar.d.ts.map +1 -1
  41. package/lib/typescript/lib/commonjs/Poll/components/CampaignResult.d.ts.map +1 -1
  42. package/lib/typescript/lib/commonjs/Poll/components/PollCard.d.ts +2 -1
  43. package/lib/typescript/lib/commonjs/Poll/components/PollCard.d.ts.map +1 -1
  44. package/lib/typescript/lib/commonjs/Poll/components/PollOptionCard.d.ts.map +1 -1
  45. package/lib/typescript/lib/commonjs/Poll/components/PollQuestionsSection.d.ts.map +1 -1
  46. package/lib/typescript/lib/commonjs/Poll/components/PollSelectCard.d.ts +1 -2
  47. package/lib/typescript/lib/commonjs/Poll/components/PollSelectCard.d.ts.map +1 -1
  48. package/lib/typescript/lib/commonjs/Poll/index.d.ts +1 -2
  49. package/lib/typescript/lib/commonjs/Poll/index.d.ts.map +1 -1
  50. package/lib/typescript/lib/module/Components/Spring.d.ts +1 -1
  51. package/lib/typescript/lib/module/Poll/components/CampaignHeader.d.ts +1 -2
  52. package/lib/typescript/lib/module/Poll/components/CampaignHeader.d.ts.map +1 -1
  53. package/lib/typescript/lib/module/Poll/components/CampaignLeaderboard.d.ts +2 -4
  54. package/lib/typescript/lib/module/Poll/components/CampaignLeaderboard.d.ts.map +1 -1
  55. package/lib/typescript/lib/module/Poll/components/CampaignProgressBar.d.ts +1 -2
  56. package/lib/typescript/lib/module/Poll/components/CampaignProgressBar.d.ts.map +1 -1
  57. package/lib/typescript/lib/module/Poll/components/CampaignResult.d.ts +1 -2
  58. package/lib/typescript/lib/module/Poll/components/CampaignResult.d.ts.map +1 -1
  59. package/lib/typescript/lib/module/Poll/components/PollCard.d.ts +3 -5
  60. package/lib/typescript/lib/module/Poll/components/PollCard.d.ts.map +1 -1
  61. package/lib/typescript/lib/module/Poll/components/PollOptionCard.d.ts +1 -2
  62. package/lib/typescript/lib/module/Poll/components/PollOptionCard.d.ts.map +1 -1
  63. package/lib/typescript/lib/module/Poll/components/PollQuestionsSection.d.ts +1 -2
  64. package/lib/typescript/lib/module/Poll/components/PollQuestionsSection.d.ts.map +1 -1
  65. package/lib/typescript/lib/module/Poll/components/PollSelectCard.d.ts +2 -4
  66. package/lib/typescript/lib/module/Poll/components/PollSelectCard.d.ts.map +1 -1
  67. package/lib/typescript/lib/module/Poll/index.d.ts +2 -4
  68. package/lib/typescript/lib/module/Poll/index.d.ts.map +1 -1
  69. package/lib/typescript/src/Poll/components/CampaignHeader.d.ts.map +1 -1
  70. package/lib/typescript/src/Poll/components/CampaignLeaderboard.d.ts +1 -2
  71. package/lib/typescript/src/Poll/components/CampaignLeaderboard.d.ts.map +1 -1
  72. package/lib/typescript/src/Poll/components/CampaignProgressBar.d.ts.map +1 -1
  73. package/lib/typescript/src/Poll/components/CampaignResult.d.ts.map +1 -1
  74. package/lib/typescript/src/Poll/components/PollCard.d.ts +3 -2
  75. package/lib/typescript/src/Poll/components/PollCard.d.ts.map +1 -1
  76. package/lib/typescript/src/Poll/components/PollOptionCard.d.ts.map +1 -1
  77. package/lib/typescript/src/Poll/components/PollQuestionsSection.d.ts.map +1 -1
  78. package/lib/typescript/src/Poll/components/PollSelectCard.d.ts +1 -1
  79. package/lib/typescript/src/Poll/components/PollSelectCard.d.ts.map +1 -1
  80. package/lib/typescript/src/Poll/index.d.ts +1 -2
  81. package/lib/typescript/src/Poll/index.d.ts.map +1 -1
  82. package/package.json +1 -1
  83. package/src/Poll/components/CampaignHeader.tsx +13 -12
  84. package/src/Poll/components/CampaignLeaderboard.tsx +41 -52
  85. package/src/Poll/components/CampaignProgressBar.tsx +17 -15
  86. package/src/Poll/components/CampaignResult.tsx +13 -13
  87. package/src/Poll/components/PollCard.tsx +129 -118
  88. package/src/Poll/components/PollOptionCard.tsx +20 -21
  89. package/src/Poll/components/PollQuestionsSection.tsx +15 -14
  90. package/src/Poll/components/PollSelectCard.tsx +47 -48
  91. package/src/Poll/index.tsx +83 -73
  92. package/lib/commonjs/Poll/components/CampaignPlay.js +0 -472
  93. package/lib/commonjs/Poll/components/CampaignPlay.js.map +0 -1
  94. package/lib/module/Poll/components/CampaignPlay.js +0 -463
  95. package/lib/module/Poll/components/CampaignPlay.js.map +0 -1
  96. package/lib/typescript/lib/commonjs/Poll/components/CampaignPlay.d.ts +0 -12
  97. package/lib/typescript/lib/commonjs/Poll/components/CampaignPlay.d.ts.map +0 -1
  98. package/lib/typescript/lib/module/Poll/components/CampaignPlay.d.ts +0 -13
  99. package/lib/typescript/lib/module/Poll/components/CampaignPlay.d.ts.map +0 -1
  100. package/lib/typescript/src/Poll/components/CampaignPlay.d.ts +0 -14
  101. package/lib/typescript/src/Poll/components/CampaignPlay.d.ts.map +0 -1
  102. package/src/Poll/components/CampaignPlay.tsx +0 -335
@@ -1,17 +1,18 @@
1
- import { FlatList, Image, ScrollView, TouchableOpacity, View } from 'react-native';
1
+ import { ActivityIndicator, FlatList, Image } from 'react-native';
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import PollOptionCard from './PollOptionCard';
4
4
  import ResponseTimer from './ResponseTimer';
5
5
  import type { PollOptionProps, PollProps, PollResponseProps, PollSummaryProps } from '../../types';
6
6
  import { PollApi } from '../api';
7
- import { Button, Icons, Text } from '../../Components';
8
- import Colors from '../../constants/colors';
9
- import { view_styles } from '../../constants/styles';
7
+ import { Icons } from '../../Components';
8
+ import { useColors } from '../../constants/useColors';
9
+ import { Button, Text, View } from '../../Components/Themed';
10
10
 
11
11
  type PollCardProps = {
12
- poll_id:string,
12
+ poll_id?:string,
13
13
  poll_response?:PollResponseProps,
14
14
  action_loading?:boolean,
15
+ width:number,
15
16
  question_number?:number,
16
17
  view?:string,
17
18
  total_questions?:number,
@@ -20,9 +21,9 @@ type PollCardProps = {
20
21
  onCancel:() => void,
21
22
  onSkip: () => void
22
23
  }
23
-
24
- const PollCard = ({ poll_id, poll_response, action_loading, onSkip, onCancel, onResponse }: PollCardProps) => {
25
- const [ poll_width, setPollWidth ] = useState(0);
24
+ const sections = ['question','image','options','selected_option', 'correct_select', 'public_results']
25
+ const PollCard = ({ poll_id, width, poll_response, action_loading, onSkip, onCancel, onResponse }: PollCardProps) => {
26
+ const Colors = useColors();
26
27
  const [ poll_data, setPollData ] = useState<{
27
28
  poll?:PollProps,
28
29
  loading:boolean,
@@ -38,6 +39,7 @@ const PollCard = ({ poll_id, poll_response, action_loading, onSkip, onCancel, on
38
39
  const correct_option = poll_options.find(o => o.result_ind == 'win');
39
40
  const responses = poll_summaries.reduce((a,b) => a + b.count, 0)
40
41
  useEffect(() => {
42
+ if(!poll_id){ return }
41
43
  getPollFromServer(poll_id)
42
44
  },[poll_id])
43
45
 
@@ -144,111 +146,127 @@ const PollCard = ({ poll_id, poll_response, action_loading, onSkip, onCancel, on
144
146
  )
145
147
  }
146
148
 
147
- if(!poll){ return <></> }
148
-
149
- return (
150
- <View nativeID='poll' style={{ ...view_styles.section, minHeight:500 }} onLayout={(ev) => {
151
- const { width } = ev.nativeEvent.layout
152
- setPollWidth(width)
153
- }}>
154
- <View style={{ ...view_styles.section_header, backgroundColor:Colors.shades.shade100 }}>
155
- <View style={{ flex:1 }}>
156
- <Text theme='header_2'>Question {poll.priority}</Text>
157
- <Text style={{ marginTop:5 }} theme='header'>{poll.poll_question}</Text>
158
- </View>
159
- </View>
160
- <ScrollView style={{ flex:1 }}>
161
- <View nativeID='question_image'>
162
- {poll?.poll_image?.url ?
163
- <Image
164
- source={{ uri:poll.poll_image.url, width:poll_width, height: poll_width*0.5 }}
165
- resizeMode='contain'
166
- />
167
- :<></>}
168
- </View>
169
-
170
- { poll.status == 'active' && !poll_response ?
171
- <View nativeID='question_respond_options'>
172
- <FlatList
173
- data={poll_options.sort((a,b) => a.priority - b.priority)}
174
- renderItem={renderPollOptions}
175
- numColumns={2}
176
- keyExtractor={(item) => item.poll_option_id.toString()}
177
- />
178
- </View>
179
- :
180
- <View nativeID='question_answer' style={{ flex:1 }}>
181
- {selected_option ?
182
- <View nativeID='selected_option' style={{ marginBottom:10, padding:10 }}>
183
- <Text style={{ marginBottom:5 }} size={14} color={Colors.brand.slate} weight='semibold'>MY SELECTED ANSWER</Text>
184
- <PollOptionCard
185
- show_result={true}
186
- show_summary={false}
187
- poll_response={poll_response}
188
- onSelect={() => console.log('Hey')}
189
- poll_option={selected_option}
190
- />
191
- </View>
192
- : (!poll_response || poll_response?.timed_out) ?
193
- <View style={{ marginBottom:10, padding:10 }}>
194
- <Text style={{ marginBottom:5 }} size={14} color={Colors.brand.slate} weight='semibold'>MY SELECTED ANSWER</Text>
195
- <View style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:22, borderWidth:1, borderColor:Colors.utility.error }}>
196
- <Text style={{ flex:1 }} size={14} color={Colors.utility.error} textAlign='center' weight='semibold'>Timed Out</Text>
197
- <Icons.CloseIcon color={Colors.utility.error} size={12}/>
149
+ const renderSections = (data:{ item:string, index:number }) => {
150
+ switch(data.item){
151
+ case 'question':
152
+ if(!poll){ return <></> }
153
+ return (
154
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:15, borderTopRightRadius:22, borderTopLeftRadius:22 }}>
155
+ <View transparent style={{ flex:1 }}>
156
+ <Text theme='h2'>Question {poll.priority}</Text>
157
+ <Text style={{ marginTop:5 }} theme='h1'>{poll.poll_question}</Text>
158
+ </View>
198
159
  </View>
199
- </View>
200
- :<></>}
201
- {poll.poll_type == 'select' && correct_option ?
202
- <View nativeID='selected_option' style={{ marginBottom:10, padding:10 }}>
203
- <Text style={{ marginBottom:5 }} size={14} color={Colors.brand.slate} weight='semibold'>CORRECT ANSWER</Text>
204
- <PollOptionCard
205
- show_summary={true}
206
- show_result={true}
207
- onSelect={() => console.log('')}
208
- poll_option={correct_option}
209
- />
210
- </View>
211
- :poll.poll_type == 'input' && poll.winning_value ?
212
- <View style={{ marginBottom:10, padding:10 }}>
213
- <Text style={{ marginBottom:5 }} size={14} color={Colors.brand.slate} weight='semibold'>CORRECT ANSWER</Text>
214
- <View style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:22, borderWidth:1, borderColor:Colors.utility.success }}>
215
- <Text style={{ flex:1 }} size={14} color={Colors.utility.success} textAlign='center' weight='semibold'>{poll.winning_value}</Text>
216
- <Icons.CheckIcon color={Colors.utility.success} size={12}/>
160
+ )
161
+ case 'image':
162
+ if(!poll?.poll_image?.url){ return <></> }
163
+ return (
164
+ <View nativeID='question_image'>
165
+ <Image
166
+ source={{ uri:poll.poll_image.url }}
167
+ style={{ width:width - 20, height:width/2}}
168
+ resizeMode='cover'
169
+ />
217
170
  </View>
218
- </View>
219
- :<></>}
220
- {poll.poll_type == 'select' ?
221
- <View nativeID='option_results' style={{ backgroundColor:Colors.shades.shade100, padding:10, borderRadius:8 }}>
222
- <View style={{ flexDirection:'row', alignItems:'center', marginBottom:5 }}>
223
- <Text style={{ flex:1 }} size={14} color={Colors.brand.slate} weight='semibold'>PUBLIC RESULTS</Text>
224
- <View style={{ borderRadius:22, padding:10, backgroundColor:Colors.accents.accent100 }}>
225
- <Text size={14} color={Colors.brand.midnight} weight='regular'>{responses} Responses</Text>
171
+ )
172
+ case 'options':
173
+ if(!poll || poll.status != 'active' || poll_response){ return <></> }
174
+ return (
175
+ <View nativeID='question_respond_options' style={{ padding:12, maxHeight:550 }}>
176
+ <FlatList
177
+ data={poll_options.sort((a,b) => a.priority - b.priority)}
178
+ renderItem={renderPollOptions}
179
+ numColumns={2}
180
+ keyExtractor={(item) => item.poll_option_id.toString()}
181
+ />
182
+ </View>
183
+ )
184
+ case 'selected_option':
185
+ if(!selected_option || !poll_response){ return <></> }
186
+ return (
187
+ <View nativeID='selected_option' style={{ marginBottom:10, padding:10 }}>
188
+ <Text style={{ marginBottom:5 }} size={14} theme='description'>MY SELECTED ANSWER</Text>
189
+ <PollOptionCard
190
+ show_result={true}
191
+ show_summary={false}
192
+ poll_response={poll_response}
193
+ onSelect={() => console.log('Hey')}
194
+ poll_option={selected_option}
195
+ />
196
+ </View>
197
+ )
198
+ case 'correct_select':
199
+ if(!poll || poll.poll_type != 'select' || !correct_option){ return <></> }
200
+ return (
201
+ <View nativeID='selected_option' style={{ marginBottom:10, padding:10 }}>
202
+ <Text style={{ marginBottom:5 }} size={14} theme='description' weight='semibold'>CORRECT ANSWER</Text>
203
+ <PollOptionCard
204
+ show_summary={true}
205
+ show_result={true}
206
+ onSelect={() => console.log('')}
207
+ poll_option={correct_option}
208
+ />
209
+ </View>
210
+ )
211
+ case 'correct_input':
212
+ if(!poll || poll.poll_type != 'input' || !poll.winning_value){ return <></> }
213
+ return (
214
+ <View style={{ marginBottom:10, padding:10 }}>
215
+ <Text style={{ marginBottom:5 }} size={14} theme='description' weight='semibold'>CORRECT ANSWER</Text>
216
+ <View style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:22, borderWidth:1, borderColor:Colors.text.success }}>
217
+ <Text style={{ flex:1 }} size={14} color={Colors.text.success} textAlign='center' weight='semibold'>{poll.winning_value}</Text>
218
+ <Icons.CheckIcon color={Colors.text.success} size={12}/>
226
219
  </View>
227
220
  </View>
228
- {!poll.show_responses ?
229
- <Text style={{ marginBottom:5 }} color={Colors.utility.warning} size={12} >Responses are hidden until closed</Text>
230
- :<></>}
231
- <FlatList
232
- data={poll_options}
233
- renderItem={renderPollOptions}
234
- keyExtractor={(item) => item.poll_option_id.toString()}
235
- />
236
- </View>
221
+ )
222
+ case 'public_results':
223
+ if(!poll || poll.poll_type != 'select' || !poll_response){ return <></> }
224
+ if(!poll.show_responses){ return <></> }
225
+ return (
226
+ <View nativeID='option_results' style={{ padding:10, borderRadius:8 }}>
227
+ <View style={{ flexDirection:'row', alignItems:'center', marginBottom:5 }}>
228
+ <Text style={{ flex:1 }} size={14} theme='description' weight='semibold'>PUBLIC RESULTS</Text>
229
+ <View style={{ borderRadius:22, padding:10 }}>
230
+ <Text size={14} theme='description'>{responses} Responses</Text>
231
+ </View>
232
+ </View>
233
+ {!poll.show_responses ?
234
+ <Text style={{ marginBottom:5 }} color={Colors.text.warning} size={12} >Responses are hidden until closed</Text>
235
+ :<></>}
236
+ <FlatList
237
+ data={poll_options}
238
+ renderItem={renderPollOptions}
239
+ keyExtractor={(item) => item.poll_option_id.toString()}
240
+ />
241
+ </View>
242
+ )
243
+ default:return <></>
244
+ }
245
+ }
246
+
247
+ return (
248
+ <View float nativeID='poll' style={{ borderRadius:22 }}>
249
+ <View transparent style={{ flex:1 }}>
250
+ {loading || !poll ?
251
+ <ActivityIndicator style={{ padding:20, alignSelf:'center' }} color={Colors.text.h1} size='large' />
237
252
  :<></>}
238
- </View>
239
- }
240
- </ScrollView>
241
- {!loading ?
242
- <View nativeID='question_actions' style={{ ...view_styles.section_footer, alignItems:undefined }}>
243
- {!poll.seconds_allowed || poll_response ?
244
- <TouchableOpacity
245
- style={{ marginRight:10, justifyContent:'center', paddingRight:20, paddingLeft:20, backgroundColor:Colors.utility.warning, borderRadius:22, borderWidth:1, borderColor:Colors.utility.warning }}
253
+ <FlatList
254
+ data={sections}
255
+ key={'poll_question_sections'}
256
+ keyExtractor={item => item}
257
+ renderItem={renderSections}
258
+ />
259
+ </View>
260
+ <View nativeID='question_actions' type='footer' style={{ flexDirection:'row', padding:12, borderBottomLeftRadius:22, borderBottomRightRadius:22 }}>
261
+ {poll && (!poll.seconds_allowed || poll_response) ?
262
+ <Button
263
+ style={{ marginRight:10, justifyContent:'center', padding:15, backgroundColor:Colors.text.warning, borderRadius:22, borderWidth:1, borderColor:Colors.text.warning }}
246
264
  onPress={() => handleCancel()}
247
265
  >
248
- <Icons.ListIcon size={18} color={Colors.shades.white} />
249
- </TouchableOpacity>
266
+ <Icons.ListIcon size={16} color={Colors.text.white} />
267
+ </Button>
250
268
  :<></>}
251
- {poll.status == 'active' && poll.seconds_allowed && !poll_response ?
269
+ {poll &&poll.status == 'active' && poll.seconds_allowed && !poll_response ?
252
270
  <View style={{ marginRight:5 }}>
253
271
  <ResponseTimer
254
272
  poll_id={poll.poll_id}
@@ -258,30 +276,23 @@ const PollCard = ({ poll_id, poll_response, action_loading, onSkip, onCancel, on
258
276
  </View>
259
277
  :
260
278
  <Button
261
- style={{flex:1, marginRight:5}}
262
- title_color={Colors.brand.electric}
279
+ style={{flex:1, marginRight:5, padding:15}}
280
+ type='action'
263
281
  title={poll_response?'Next':'Skip'}
264
- borderColor={Colors.brand.electric}
265
- backgroundColor={Colors.shades.white}
266
- borderRadius={22}
267
- borderWidth={1}
268
- padding={14}
269
282
  onPress={() => handleSkip()}
270
283
  />
271
284
  }
272
- {!poll_response ?
285
+ {poll && !poll_response && !loading ?
273
286
  <Button
274
- style={{flex:2}}
275
- title_color={Colors.shades.white}
287
+ style={{flex:2, padding:15, opacity: selected_option && !action_loading ? 1 : 0.5}}
288
+ loading={action_loading}
276
289
  disabled={selected_option&&!action_loading?false:true}
290
+ type='success'
277
291
  title={selected_option?`Submit!`:poll.status == 'active' ? 'Select Answer' : 'Not Active'}
278
- backgroundColor={selected_option&&!action_loading?Colors.utility.success:Colors.brand.slate}
279
- borderRadius={22}
280
292
  onPress={() => handleSubmitResponse()}
281
293
  />
282
294
  :<></>}
283
295
  </View>
284
- :<></>}
285
296
  </View>
286
297
 
287
298
  )
@@ -1,8 +1,9 @@
1
1
  import React, { useState } from "react";
2
- import { TextInput, TouchableOpacity, View } from "react-native"
2
+ import { TextInput } from "react-native"
3
3
  import type { PollOptionProps, PollResponseProps, PollSummaryProps } from "../../types";
4
- import Colors from "../../constants/colors";
5
- import { Button, Icons, Text } from "../../Components";
4
+ import { Icons } from "../../Components";
5
+ import { useColors } from "../../constants/useColors";
6
+ import { Button, Text, View } from "../../Components/Themed";
6
7
 
7
8
  type PollOptionCardProps = {
8
9
  poll_option:PollOptionProps,
@@ -14,16 +15,17 @@ type PollOptionCardProps = {
14
15
  onSelect: (PollOptionProps: PollOptionProps) => void
15
16
  }
16
17
  const PollOptionCard = ({ draft_selected, show_result, poll_option, poll_summary, show_summary, onSelect, poll_response } : PollOptionCardProps) => {
18
+ const Colors = useColors();
17
19
  const [ option_width, setOptionWidth ] = useState(0);
18
20
  const [ input_locked, setInputLocked ] = useState(false);
19
21
  const [ input_value, setInputValue ] = useState('');
20
22
 
21
23
  const getResultColor = (result_ind?:'win'|'lose'|'draw') => {
22
24
  switch(result_ind){
23
- case 'win': return Colors.utility.success
24
- case 'lose': return Colors.utility.error
25
- case 'draw': return Colors.utility.warning
26
- default: return Colors.brand.slate
25
+ case 'win': return Colors.text.success
26
+ case 'lose': return Colors.text.error
27
+ case 'draw': return Colors.text.warning
28
+ default: return Colors.text.h1
27
29
  }
28
30
  }
29
31
 
@@ -41,39 +43,38 @@ const PollOptionCard = ({ draft_selected, show_result, poll_option, poll_summary
41
43
  return (
42
44
  <View>
43
45
  {poll_option.option_type == 'select' ?
44
- <TouchableOpacity
45
- style={{ flex:1, flexDirection:'row', alignItems:'center', padding:10, borderRadius:22, borderWidth:1, borderColor:show_result?getResultColor(poll_option.result_ind):Colors.shades.shade600, backgroundColor:draft_selected?Colors.highlights.highlight500Faded:undefined }}
46
+ <Button
47
+ style={{ flex:1, flexDirection:'row', alignItems:'center', padding:10, borderRadius:22, borderWidth:1, borderColor:show_result?getResultColor(poll_option.result_ind):Colors.borders.light, backgroundColor:draft_selected?Colors.absolutes.highlights.highlight500Faded:undefined }}
46
48
  onPress={() => onSelect(poll_option)}
47
49
  onLayout={(ev) => {
48
50
  const { width } = ev.nativeEvent.layout
49
51
  setOptionWidth(width)
50
52
  }}
51
53
  >
52
- <Text style={{ flex:1 }} textAlign="center" size={14} color={show_result?getResultColor(poll_option.result_ind):Colors.brand.midnight} weight='bold'>{poll_option.option_name}</Text>
54
+ <Text style={{ flex:1 }} textAlign="center" size={14} color={show_result?getResultColor(poll_option.result_ind):Colors.text.h1} weight='bold'>{poll_option.option_name}</Text>
53
55
  {show_result && poll_option.result_ind ?
54
- <View>
56
+ <View transparent>
55
57
  {getResultIcon(poll_option.result_ind)}
56
58
  </View>
57
59
  :<></>}
58
60
  {show_summary && poll_summary?
59
- <View style={{ position: 'absolute', left:0, top:0, bottom:0, width:poll_summary.pct*option_width, borderRadius:22, backgroundColor:Colors.highlights.highlight400Faded }} />
61
+ <View transparent style={{ position: 'absolute', left:0, top:0, bottom:0, width:poll_summary.pct*option_width, borderRadius:22, backgroundColor:Colors.absolutes.highlights.highlight400Faded }} />
60
62
  :<></>}
61
63
  {show_summary && poll_summary ?
62
- <View style={{ position:'absolute', right:5, top:0, bottom:0, justifyContent:'center' }}>
63
- <Text weight='regular' size={10} color={Colors.brand.midnight}>{(poll_summary.pct * 100).toFixed(2)}%</Text>
64
+ <View transparent style={{ position:'absolute', right:5, top:0, bottom:0, justifyContent:'center' }}>
65
+ <Text weight='regular' size={10} color={Colors.text.h1}>{(poll_summary.pct * 100).toFixed(2)}%</Text>
64
66
  </View>
65
67
  :<></>}
66
- </TouchableOpacity>
68
+ </Button>
67
69
  :
68
70
  <View style={{ flexDirection:'row' }}>
69
- <View style={{ flex:1, flexDirection:'row', alignItems:'center', paddingRight:10, borderRadius:22, borderWidth: 1, borderColor: show_result?getResultColor(poll_response?.result_ind):Colors.shades.shade600 }}>
71
+ <View style={{ flex:1, flexDirection:'row', alignItems:'center', paddingRight:10, borderRadius:22, borderWidth: 1, borderColor: show_result?getResultColor(poll_response?.result_ind):Colors.borders.light }}>
70
72
  <TextInput
71
73
  style={{ flex:1, textAlign:'center', fontSize:14, padding:10, color:getResultColor(poll_response?.result_ind) }}
72
74
  keyboardType={poll_option.input_type == 'number' ? 'decimal-pad' : 'default'}
73
75
  editable={show_result?false:true}
74
76
  placeholder="Input Answer"
75
77
  value={poll_response ? poll_response.input_value : input_value}
76
- placeholderTextColor={Colors.shades.shade600}
77
78
  onChangeText={(text) => {
78
79
  if(draft_selected){ onSelect(poll_option) }
79
80
  setInputValue(text)
@@ -88,11 +89,9 @@ const PollOptionCard = ({ draft_selected, show_result, poll_option, poll_summary
88
89
  </View>
89
90
  {!show_result ?
90
91
  <Button
91
- style={{ marginLeft:5 }}
92
- borderRadius={22}
92
+ style={{ marginLeft:5, opacity: input_locked?1:0.5 }}
93
93
  title={input_locked?'Locked In':'Lock It In'}
94
- backgroundColor={input_locked?Colors.brand.slate:Colors.brand.electric}
95
- title_color={Colors.shades.white}
94
+ type='action'
96
95
  onPress={() => {
97
96
  if(!input_value || input_value == ''){ return alert('Please enter valid value') }
98
97
  setInputLocked(true)
@@ -1,10 +1,10 @@
1
1
  import React, { useState } from 'react';
2
- import { View, TouchableOpacity, FlatList } from "react-native"
2
+ import { FlatList } from "react-native"
3
3
  import type { PollCampaignProps, PollProps, PollResponseProps } from "../../types"
4
- import { view_styles } from '../../constants/styles';
5
- import { Icons, Text } from '../../Components';
6
- import Colors from '../../constants/colors';
4
+ import { Icons } from '../../Components';
7
5
  import PollSelectCard from './PollSelectCard';
6
+ import { Button, Text, View } from '../../Components/Themed';
7
+ import { useColors } from '../../constants/useColors';
8
8
 
9
9
  type PollQuestionsSectionProps = {
10
10
  poll_campaign:PollCampaignProps,
@@ -14,6 +14,7 @@ type PollQuestionsSectionProps = {
14
14
  }
15
15
 
16
16
  const PollQuestionsSection = ({ poll_campaign, polls, poll_responses, onSelectPoll }:PollQuestionsSectionProps) => {
17
+ const Colors = useColors();
17
18
  const [ section_data, setSectionData ] = useState<{
18
19
  loading:boolean,
19
20
  expanded:boolean,
@@ -28,7 +29,7 @@ const PollQuestionsSection = ({ poll_campaign, polls, poll_responses, onSelectPo
28
29
  const my_response = poll_responses.find(r => r.poll_id == data.item.poll_id)
29
30
  const response_option = data.item.poll_options?.find(po => po.poll_option_id == my_response?.poll_option_id);
30
31
  return (
31
- <View style={{ borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }}>
32
+ <View transparent style={{ borderBottomWidth:1, borderBottomColor:Colors.borders.light }}>
32
33
  <PollSelectCard
33
34
  poll={data.item}
34
35
  disabled={false}
@@ -44,17 +45,17 @@ const PollQuestionsSection = ({ poll_campaign, polls, poll_responses, onSelectPo
44
45
  }
45
46
 
46
47
  return (
47
- <View style={{ ...view_styles.section }}>
48
- <TouchableOpacity style={{ ...view_styles.section_header }} onPress={() => setSectionData({ ...section_data, expanded: !expanded })}>
49
- <Icons.QuestionIcon size={18} color={Colors.brand.midnight} />
50
- <View style={{flex:1, marginLeft:10}}>
51
- <Text theme='header'>Questions</Text>
52
- <Text style={{ marginTop:3 }} theme='body'>Available questions can be found below</Text>
48
+ <View float>
49
+ <Button style={{ flexDirection:'row', alignItems:'center', padding:20, backgroundColor:Colors.views.header }} onPress={() => setSectionData({ ...section_data, expanded: !expanded })}>
50
+ <Icons.QuestionIcon size={18} color={Colors.text.h1} />
51
+ <View transparent style={{flex:1, marginLeft:10}}>
52
+ <Text theme='h1'>Questions</Text>
53
+ <Text style={{ marginTop:3 }} theme='description'>Available questions can be found below</Text>
53
54
  </View>
54
- <Icons.ChevronIcon direction={expanded?'up':'down'} color={Colors.brand.midnight} size={8} />
55
- </TouchableOpacity>
55
+ <Icons.ChevronIcon direction={expanded?'up':'down'} color={Colors.text.h1} size={8} />
56
+ </Button>
56
57
  {expanded ?
57
- <View style={{ ...view_styles.section_body }}>
58
+ <View transparent type='body' style={{ padding:10 }}>
58
59
  <FlatList
59
60
  data={polls.sort((a,b) => a.priority - b.priority)}
60
61
  renderItem={renderPolls}
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import { TouchableOpacity, View } from "react-native"
3
2
  import type { PollCampaignProps, PollOptionProps, PollProps, PollResponseProps } from "../../types"
4
- import Colors from "../../constants/colors"
5
- import { Icons, Text } from "../../Components"
3
+ import { Icons } from "../../Components"
4
+ import { useColors } from '../../constants/useColors';
5
+ import { Button, Text, View } from '../../Components/Themed';
6
6
 
7
7
  type PollSelectCardProps = {
8
8
  selected?:boolean,
@@ -15,29 +15,28 @@ type PollSelectCardProps = {
15
15
  onSelect:(poll:PollProps) => void
16
16
  }
17
17
 
18
- const PollSelectCard = ({ poll, disabled, selected, poll_campaign, poll_response, show_response, response_option, onSelect }:PollSelectCardProps) => {
19
-
18
+ const PollSelectCard = ({ poll, disabled, poll_campaign, poll_response, show_response, response_option, onSelect }:PollSelectCardProps) => {
19
+ const Colors = useColors();
20
20
  const getResultColor = () => {
21
21
  switch(poll_response?.result_ind){
22
- case 'win': return Colors.utility.success
23
- case 'lose': return Colors.utility.error
24
- case 'draw': return Colors.utility.warning
25
- default: return Colors.brand.slate
22
+ case 'win': return Colors.text.success
23
+ case 'lose': return Colors.text.error
24
+ case 'draw': return Colors.text.warning
25
+ default: return Colors.text.h1
26
26
  }
27
27
  }
28
28
 
29
29
  const getStatusColor = () => {
30
30
  switch(poll.status) {
31
- case 'closed': return Colors.highlights.highlight300Faded
32
- case 'active': return Colors.highlights.highlight400Faded
33
- default: return Colors.highlights.highlight500Faded
31
+ case 'closed': return Colors.absolutes.highlights.highlight300Faded
32
+ case 'active': return Colors.absolutes.highlights.highlight400Faded
33
+ default: return Colors.absolutes.highlights.highlight500Faded
34
34
  }
35
35
  }
36
36
 
37
37
 
38
38
  const getResultIcon = () => {
39
39
  let color = getResultColor()
40
- console.log(poll_response)
41
40
  switch(poll_response?.result_ind){
42
41
  case 'win':
43
42
  return <Icons.CheckIcon color={color} size={16} />
@@ -56,51 +55,51 @@ const PollSelectCard = ({ poll, disabled, selected, poll_campaign, poll_response
56
55
  //let color = getResultColor()
57
56
  switch(poll.status){
58
57
  case 'closed':
59
- return <Icons.LockClosedIcon color={Colors.brand.midnight} size={14} />
58
+ return <Icons.LockClosedIcon color={Colors.text.h1} size={14} />
60
59
  case 'active':
61
- return <Icons.InProgressIcon color={Colors.brand.midnight} size={14} />
60
+ return <Icons.InProgressIcon color={Colors.text.h1} size={14} />
62
61
  default:
63
- return <Icons.PausedIcon color={Colors.brand.midnight} size={14} />
62
+ return <Icons.PausedIcon color={Colors.text.h1} size={14} />
64
63
  }
65
64
  }
66
65
 
67
66
  return (
68
- <TouchableOpacity disabled={disabled} style={{ padding:10, borderRadius:22, backgroundColor:selected?Colors.highlights.highlight500Faded:undefined, flexDirection:'row' }} onPress={() => onSelect(poll)}>
69
- <View style={{ height:20, width:20, borderRadius:100, backgroundColor:Colors.shades.white, marginRight:10, justifyContent:'center' }}>
70
- <Text size={12} color={Colors.brand.midnight} weight='bold' textAlign='center'>{poll.priority}</Text>
71
- </View>
72
- <View style={{ flex:1 }}>
73
- {poll_campaign.campaign_type == 'trivia' && !poll_response && poll.status != 'closed' ?
74
- <Text size={14} color={Colors.brand.midnight} weight='bold'>{poll.hidden_clue?`Hint: ${poll.hidden_clue}`:`Question Hidden`}</Text>
75
- :
76
- <Text size={14} color={Colors.brand.midnight} weight='bold'>{poll.poll_question}</Text>
77
- }
78
- {poll.status == 'closed' || show_response ?
79
- <View style={{ marginTop:10, flexDirection:'row' }}>
80
- {response_option && poll.poll_type == 'select' ?
81
- <Text style={{ flex:1 }} size={12} color={Colors.brand.slate}>My Answer: <Text size={12} color={Colors.brand.midnight} weight='semibold'>{response_option.option_name}</Text></Text>
82
- : response_option && poll.poll_type == 'input' ?
83
- <Text style={{ flex:1 }} size={12} color={Colors.brand.slate}>My Answer: <Text size={12} color={Colors.brand.midnight} weight='semibold'>{poll_response?.input_value}</Text></Text>
84
- :poll.status == 'closed' || poll_response?.timed_out ?
85
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='light'>TIMED OUT</Text>
86
- :<></>}
87
- <View style={{ marginLeft:5 }}>
88
- {getResultIcon()}
89
- </View>
67
+ <Button transparent disabled={disabled} style={{ padding:10, borderRadius:22, flexDirection:'row' }} onPress={() => onSelect(poll)}>
68
+ <View transparent style={{ height:20, width:20, borderRadius:100, marginRight:10, justifyContent:'center' }}>
69
+ <Text size={12} color={Colors.text.h1} weight='bold' textAlign='center'>{poll.priority}</Text>
90
70
  </View>
91
- :
92
- <View style={{flexDirection:'row', alignItems:'center'}}>
93
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='light'>{poll.poll_type == 'select' ? 'Multiple Choice': 'Type Answer'}</Text>
94
- <View style={{ flexDirection:'row', alignItems:'center', padding:10, backgroundColor:getStatusColor(), borderRadius:22 }}>
95
- {getStatusIcon()}
96
- {poll.seconds_allowed && poll.status != 'closed' ?
97
- <Text style={{ marginLeft:5 }} size={12} color={Colors.brand.midnight} weight='bold'>{poll.seconds_allowed} Sec</Text>
71
+ <View transparent style={{ flex:1 }}>
72
+ {poll_campaign.campaign_type == 'trivia' && !poll_response && poll.status != 'closed' ?
73
+ <Text size={14} color={Colors.text.h1} weight='bold'>{poll.hidden_clue?`Hint: ${poll.hidden_clue}`:`Question Hidden`}</Text>
74
+ :
75
+ <Text size={14} color={Colors.text.h1} weight='bold'>{poll.poll_question}</Text>
76
+ }
77
+ {poll.status == 'closed' || show_response ?
78
+ <View transparent style={{ marginTop:10, flexDirection:'row' }}>
79
+ {response_option && poll.poll_type == 'select' ?
80
+ <Text style={{ flex:1 }} size={12} color={Colors.text.h1}>My Answer: <Text size={12} color={Colors.text.h1} theme='h2'>{response_option.option_name}</Text></Text>
81
+ : response_option && poll.poll_type == 'input' ?
82
+ <Text style={{ flex:1 }} size={12} color={Colors.text.h1}>My Answer: <Text size={12} color={Colors.text.h1} theme='h2'>{poll_response?.input_value}</Text></Text>
83
+ :poll.status == 'closed' || poll_response?.timed_out ?
84
+ <Text style={{ flex:1 }} size={12} color={Colors.text.h1} weight='light'>TIMED OUT</Text>
98
85
  :<></>}
86
+ <View style={{ marginLeft:5 }}>
87
+ {getResultIcon()}
88
+ </View>
99
89
  </View>
90
+ :
91
+ <View transparent style={{flexDirection:'row', alignItems:'center'}}>
92
+ <Text style={{ flex:1 }} size={12} color={Colors.text.h1} weight='light'>{poll.poll_type == 'select' ? 'Multiple Choice': 'Type Answer'}</Text>
93
+ <View transparent style={{ flexDirection:'row', alignItems:'center', padding:10, backgroundColor:getStatusColor(), borderRadius:22 }}>
94
+ {getStatusIcon()}
95
+ {poll.seconds_allowed && poll.status != 'closed' ?
96
+ <Text style={{ marginLeft:5 }} size={12} color={Colors.text.h1} weight='bold'>{poll.seconds_allowed} Sec</Text>
97
+ :<></>}
98
+ </View>
99
+ </View>
100
+ }
100
101
  </View>
101
- }
102
- </View>
103
- </TouchableOpacity>
102
+ </Button>
104
103
  )
105
104
  }
106
105