@@ -186,52 +186,69 @@ fun PrimaryFeatures(
186
186
@Composable
187
187
private fun FinancialTipCard (
188
188
tipInterface : FinancialTipClickInterface ? ,
189
- financialTip : FinancialTip
189
+ financialTip : FinancialTip ,
190
+ homeViewModel : HomeViewModel ?
190
191
) {
191
192
val size13 = dimensionResource(id = R .dimen.margin_13)
192
- Card (elevation = 0 .dp, modifier = Modifier .padding(all = size13)) {
193
- Row (modifier = Modifier
194
- .padding(all = size13)
195
- .clickable { tipInterface?.onTipClicked(null ) }) {
196
193
197
- Column (modifier = Modifier .weight(1f )) {
194
+ Card (elevation = 0 .dp, modifier = Modifier .padding(all = size13)) {
195
+ Column {
196
+ Row (modifier = Modifier
197
+ .fillMaxWidth()
198
+ .padding(all = size13)) {
198
199
HorizontalImageTextView (
199
200
drawable = R .drawable.ic_tip_of_day,
200
201
stringRes = R .string.tip_of_the_day,
201
- Modifier .padding(bottom = 5 .dp ),
202
+ Modifier .weight( 1f ),
202
203
MaterialTheme .typography.button
203
204
)
204
205
205
- Spacer (modifier = Modifier .height(10 .dp))
206
-
207
- Text (
208
- text = financialTip.title,
209
- style = MaterialTheme .typography.body2,
210
- textDecoration = TextDecoration .Underline
211
- )
206
+ Image (painter = painterResource(id = R .drawable.ic_close_white),
207
+ contentDescription = null ,
208
+ alignment = Alignment .CenterEnd ,
209
+ modifier = Modifier .clickable { homeViewModel?.dismissTip(financialTip.id) })
210
+ }
212
211
213
- Spacer (modifier = Modifier .height(8 .dp))
212
+ Row (modifier = Modifier
213
+ .padding(horizontal = size13)
214
+ .clickable { tipInterface?.onTipClicked(null ) }) {
215
+
216
+ Column (modifier = Modifier .weight(1f )) {
217
+ Spacer (modifier = Modifier .height(10 .dp))
218
+
219
+ Text (
220
+ text = financialTip.title,
221
+ style = MaterialTheme .typography.body2,
222
+ textDecoration = TextDecoration .Underline
223
+ )
224
+
225
+ Spacer (modifier = Modifier .height(8 .dp))
226
+
227
+ Text (
228
+ text = financialTip.snippet,
229
+ style = MaterialTheme .typography.body2,
230
+ maxLines = 2 ,
231
+ overflow = TextOverflow .Ellipsis ,
232
+ modifier = Modifier .padding(bottom = size13, top = 3 .dp)
233
+ )
234
+
235
+ Text (text = stringResource(id = R .string.read_more),
236
+ color = colorResource(id = R .color.brightBlue),
237
+ modifier = Modifier
238
+ .padding(bottom = size13)
239
+ .clickable { tipInterface?.onTipClicked(financialTip.id) }
240
+ )
241
+ }
214
242
215
- Text (
216
- text = financialTip.snippet,
217
- style = MaterialTheme .typography.body2,
218
- maxLines = 2 ,
219
- overflow = TextOverflow .Ellipsis ,
220
- modifier = Modifier .padding(bottom = size13, top = 3 .dp)
243
+ Image (
244
+ painter = painterResource(id = R .drawable.tips_fancy_icon),
245
+ contentDescription = null ,
246
+ modifier = Modifier
247
+ .size(60 .dp)
248
+ .padding(start = size13)
249
+ .align(Alignment .CenterVertically ),
221
250
)
222
- Text (text = stringResource(id = R .string.read_more),
223
- color = colorResource(id = R .color.brightBlue),
224
- modifier = Modifier .clickable { tipInterface?.onTipClicked(financialTip.id) })
225
251
}
226
-
227
- Image (
228
- painter = painterResource(id = R .drawable.tips_fancy_icon),
229
- contentDescription = null ,
230
- modifier = Modifier
231
- .size(60 .dp)
232
- .padding(start = size13)
233
- .align(Alignment .CenterVertically ),
234
- )
235
252
}
236
253
}
237
254
}
@@ -372,10 +389,12 @@ fun HomeScreen(
372
389
homeState.financialTips.firstOrNull {
373
390
android.text.format.DateUtils .isToday(it.date!! )
374
391
}?.let {
375
- FinancialTipCard (
376
- tipInterface = tipInterface,
377
- financialTip = homeState.financialTips.first()
378
- )
392
+ if (homeState.dismissedTipId != it.id)
393
+ FinancialTipCard (
394
+ tipInterface = tipInterface,
395
+ financialTip = homeState.financialTips.first(),
396
+ homeViewModel
397
+ )
379
398
}
380
399
}
381
400
}
@@ -435,7 +454,7 @@ fun HomeScreenPreview() {
435
454
BalanceScreenPreview ()
436
455
}
437
456
item {
438
- FinancialTipCard (tipInterface = null , financialTip = financialTip)
457
+ FinancialTipCard (tipInterface = null , financialTip = financialTip, null )
439
458
}
440
459
})
441
460
})
0 commit comments