/
deals.dart
135 lines (130 loc) · 5.09 KB
/
deals.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import 'dart:math';
import 'package:material_design_icons_flutter/material_design_icons_flutter.dart';
import '../data/data.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:omnikit/controllers/mas_controller.dart';
import 'package:omnikit/models/models.dart';
// import 'package:omnikit/services/backend_auth_service.dart';
class Deals extends StatelessWidget {
final String title;
final List<Content> contentList;
const Deals({Key key, this.title, this.contentList}) : super(key: key);
@override
Widget build(BuildContext context) {
// BackEndAuthService authRequest = BackEndAuthService();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 24.0),
child: Text(
title,
style: const TextStyle(
color: Colors.black87,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
Container(
height: 165.0,
child: ListView.builder(
physics: BouncingScrollPhysics(),
padding:
const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0),
scrollDirection: Axis.horizontal,
itemCount: contentList.length,
itemBuilder: (BuildContext context, int index) {
final Content content = contentList[index];
return GetBuilder<MASController>(
builder: (val) => GestureDetector(
onTap: () {
// authRequest.getBearer();
Map<String, dynamic> payload = generatePayload();
print('from deals');
// print(val.data.toString());
val.runClickPredModel(
val.data['access_token'].toString(), payload);
Future.delayed(Duration(milliseconds: 500), () {
Get.snackbar('Click Prediction Probability',
'⚡️ SAS AI Click Score ${(double.parse(val.eMClickPredResponse) * 100).toStringAsFixed(2)}%',
colorText: Colors.white,
snackPosition: SnackPosition.BOTTOM,
backgroundColor: Colors.blueAccent,
borderWidth: Get.width,
icon: Icon(MdiIcons.api, color: Colors.white),
shouldIconPulse: true);
});
print(content.name);
},
child: Stack(
alignment: Alignment.center,
children: [
Container(
height: 130.0,
width: 130.0,
margin: const EdgeInsets.symmetric(horizontal: 16.0),
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage(content.imageUrl),
fit: BoxFit.cover,
),
shape: BoxShape.circle,
border: Border.all(
color: content.color,
width: 2.0,
),
),
),
Container(
height: 130.0,
width: 130.0,
decoration: BoxDecoration(
gradient: const LinearGradient(
colors: [
Colors.black87,
Colors.black45,
Colors.transparent,
],
stops: [0, 0.25, 1],
begin: Alignment.bottomCenter,
end: Alignment.topCenter,
),
shape: BoxShape.circle,
border: Border.all(color: content.color, width: 4.0),
),
),
Positioned(
left: 0,
right: 0,
bottom: 60,
child: SizedBox(
height: 15.0,
child: Text(
content.name,
style: TextStyle(
color: Colors.white,
fontSize: 9.0,
fontWeight: FontWeight.bold),
maxLines: 2,
textAlign: TextAlign.center,
),
),
),
],
),
),
);
},
),
)
],
);
}
Map<String, dynamic> generatePayload() {
Random randX = Random();
int index = randX.nextInt(3);
return clickPredData[index];
}
}