-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetailPage.dart
218 lines (167 loc) · 6.12 KB
/
DetailPage.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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:http/http.dart' as http;
import 'dart:async';
import 'dart:convert';
import 'package:tv/ImageDetails.dart';
import 'package:tv/video.dart';
class DetailPage extends StatefulWidget {
final String id;
final String title;
DetailPage(this.id, this.title);
@override
_DetailPageState createState() => _DetailPageState();
}
class _DetailPageState extends State<DetailPage> {
bool _loading=true;
Map data;
List userData;
String image;
Future getData() async {
String id=widget.id;
http.Response response = await http.get("http://lhtvapp.com//api.php?cat_id=$id");
data = json.decode(response.body);
//debugPrint(response.body);
print(id);
setState(() {
userData = data["NEWS_APP"];
_loading=false;
});
}
@override
void initState() {
// TODO: implement initState
super.initState();
getData();
}
@override
Widget build(BuildContext context) {
String title=widget.title;
return Scaffold(
appBar: AppBar(
backgroundColor:Colors.white,
automaticallyImplyLeading:true,
leading: IconButton(
icon:Icon(
Icons.arrow_back_ios,color: Colors.amber[800]),
onPressed: () => Navigator.of(context).pop(),
),
elevation: 0.0,
title:Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Image.asset(
'images/logo.png',
height: 100,
),
],
)
),
body:_loading ? Center(
child: Container(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation<Color>(Colors.amber[800]),
),
),
) :
Padding(
padding: EdgeInsets.all(8.0),
child: Container(
child: Column(
children: <Widget>[
Text(title,style:TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold
),),
SizedBox(height: 10,),
Text('So faith comes from hearing, and hearing through the word of Christ (Romans 10:17)'
,style:TextStyle(
color: Colors.black54,
fontWeight: FontWeight.bold
),),
SizedBox(height: 10,),
Expanded(
child: GridView.builder(
padding:EdgeInsets.only(top:12),
shrinkWrap: true,
itemCount:userData == null ? 0 : userData.length,
gridDelegate:new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (BuildContext context,int index){
String new_type=userData[index]['news_type'];
if(new_type=="image") {
image = userData[index]['news_image_b'];
}else{
String thumb=userData[index]['video_id'];
image =userData[index]['video_id']='https://img.youtube.com/vi/${thumb}/hqdefault.jpg';
}
return new GestureDetector(
onTap: (){
new_type=userData[index]['news_type'];
if(new_type=="image"){
String des=userData[index]['news_description'];
Navigator.of(context).push(MaterialPageRoute(
builder:(context)=>ImageDetails(userData[index]['id'],userData[index]['news_title'],userData[index]['news_image_s'],userData[index]['news_description']),
)
);
}else{
Navigator.of(context).push(MaterialPageRoute(
builder:(context)=>Video(userData[index]['video_url'],userData[index]['news_title'],userData[index]['news_description']),
)
);
}
},
child: new Card(
shape:RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
child: new Container(
alignment: Alignment.center,
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: <Widget>[
Expanded
(child:
ClipRRect(
borderRadius: BorderRadius.circular(10.0),
child: Image.network(image,fit: BoxFit.cover,))),
Center(
child: Container(
child: Text(userData[index]["news_title"],style:TextStyle(
fontSize:11,
fontWeight:FontWeight.bold
),),
),
)
],
),
),
),
);
},
),
),
],
),
),
/* child:GridView.builder(
itemCount: 20,
gridDelegate:new SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 3),
itemBuilder: (BuildContext context,int index){
return new GestureDetector(
child: new Card(
child: new Container(
child: Column(
children: <Widget>[
Text('Item $index')
],
),
0 ),
),
);
},
),*/
),
);
}
}