tangheem pdf screen, content info added & improvement.
parent
8d889e502f
commit
fd97e40e12
Binary file not shown.
@ -0,0 +1,73 @@
|
||||
class ContentInfoModel {
|
||||
int totalItemsCount;
|
||||
int statusCode;
|
||||
String message;
|
||||
List<ContentInfoDataModel> data;
|
||||
|
||||
ContentInfoModel(
|
||||
{this.totalItemsCount, this.statusCode, this.message, this.data});
|
||||
|
||||
ContentInfoModel.fromJson(Map<String, dynamic> json) {
|
||||
totalItemsCount = json['totalItemsCount'];
|
||||
statusCode = json['statusCode'];
|
||||
message = json['message'];
|
||||
if (json['data'] != null) {
|
||||
data = new List<ContentInfoDataModel>();
|
||||
json['data'].forEach((v) {
|
||||
data.add(new ContentInfoDataModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['totalItemsCount'] = this.totalItemsCount;
|
||||
data['statusCode'] = this.statusCode;
|
||||
data['message'] = this.message;
|
||||
if (this.data != null) {
|
||||
data['data'] = this.data.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
class ContentInfoDataModel {
|
||||
int contentInfoId;
|
||||
int contentTypeId;
|
||||
String content;
|
||||
String contentTypeNameEn;
|
||||
String contentTypeNameAr;
|
||||
String fileName;
|
||||
String exposeFilePath;
|
||||
|
||||
ContentInfoDataModel(
|
||||
{this.contentInfoId,
|
||||
this.contentTypeId,
|
||||
this.content,
|
||||
this.contentTypeNameEn,
|
||||
this.contentTypeNameAr,
|
||||
this.fileName,
|
||||
this.exposeFilePath});
|
||||
|
||||
ContentInfoDataModel.fromJson(Map<String, dynamic> json) {
|
||||
contentInfoId = json['contentInfoId'];
|
||||
contentTypeId = json['contentTypeId'];
|
||||
content = json['content'];
|
||||
contentTypeNameEn = json['contentTypeNameEn'];
|
||||
contentTypeNameAr = json['contentTypeNameAr'];
|
||||
fileName = json['fileName'];
|
||||
exposeFilePath = json['exposeFilePath'];
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['contentInfoId'] = this.contentInfoId;
|
||||
data['contentTypeId'] = this.contentTypeId;
|
||||
data['content'] = this.content;
|
||||
data['contentTypeNameEn'] = this.contentTypeNameEn;
|
||||
data['contentTypeNameAr'] = this.contentTypeNameAr;
|
||||
data['fileName'] = this.fileName;
|
||||
data['exposeFilePath'] = this.exposeFilePath;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/svg.dart';
|
||||
import 'package:tangheem/api/tangheem_user_api_client.dart';
|
||||
import 'package:tangheem/classes/colors.dart';
|
||||
import 'package:tangheem/classes/utils.dart';
|
||||
import 'package:tangheem/models/content_info_model.dart';
|
||||
import 'package:tangheem/models/member_model.dart';
|
||||
import 'package:tangheem/ui/misc/no_data_ui.dart';
|
||||
|
||||
class ContentInfoScreen extends StatefulWidget {
|
||||
static const String routeName = "/content_info";
|
||||
final int contentId;
|
||||
ContentInfoScreen({Key key, this.contentId}) : super(key: key);
|
||||
|
||||
@override
|
||||
_ContentInfoScreenState createState() => _ContentInfoScreenState();
|
||||
}
|
||||
|
||||
class _ContentInfoScreenState extends State<ContentInfoScreen> {
|
||||
List<ContentInfoDataModel> contentList;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
getContents();
|
||||
}
|
||||
|
||||
void getContents() async {
|
||||
Utils.showLoading(context);
|
||||
try {
|
||||
var membersData = await TangheemUserApiClient().getContentInfo(widget.contentId);
|
||||
contentList = membersData?.data ?? [];
|
||||
} catch (ex, tr) {
|
||||
contentList = [];
|
||||
Utils.handleException(ex, null);
|
||||
} finally {
|
||||
Utils.hideLoading(context);
|
||||
}
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return contentList == null
|
||||
? SizedBox()
|
||||
: contentList.isEmpty
|
||||
? NoDataUI()
|
||||
: ListView.separated(
|
||||
physics: BouncingScrollPhysics(),
|
||||
padding: EdgeInsets.all(16),
|
||||
itemCount: contentList.length,
|
||||
separatorBuilder: (context, index) {
|
||||
return SizedBox(height: 8);
|
||||
},
|
||||
itemBuilder: (context, index) {
|
||||
return ListTile(
|
||||
tileColor: Colors.white,
|
||||
leading: Container(
|
||||
width: 50.0,
|
||||
height: 50.0,
|
||||
decoration: BoxDecoration(
|
||||
image: contentList.length < 1
|
||||
? null
|
||||
: DecorationImage(
|
||||
fit: BoxFit.cover,
|
||||
image: NetworkImage(contentList.elementAt(index).exposeFilePath),
|
||||
),
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(12.0),
|
||||
),
|
||||
),
|
||||
child: contentList.length < 1
|
||||
? ClipRRect(
|
||||
borderRadius: BorderRadius.all(
|
||||
Radius.circular(30.0),
|
||||
),
|
||||
child: SvgPicture.asset(
|
||||
"assets/icons/chat_user.svg",
|
||||
clipBehavior: Clip.antiAlias,
|
||||
),
|
||||
)
|
||||
: null,
|
||||
),
|
||||
title: Text(
|
||||
contentList[index].contentTypeNameAr,
|
||||
style: TextStyle(fontSize: 14, color: ColorConsts.primaryBlue),
|
||||
),
|
||||
subtitle: Text(
|
||||
" ${contentList[index].content}",
|
||||
style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue),
|
||||
),
|
||||
isThreeLine: true,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,38 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:syncfusion_flutter_pdfviewer/pdfviewer.dart';
|
||||
|
||||
class PdfViewerScreen extends StatefulWidget {
|
||||
static const String routeName = "/tangheem_pdf";
|
||||
PdfViewerScreen({Key key}) : super(key: key);
|
||||
|
||||
@override
|
||||
_PdfViewerScreenState createState() {
|
||||
return _PdfViewerScreenState();
|
||||
}
|
||||
}
|
||||
|
||||
class _PdfViewerScreenState extends State<PdfViewerScreen> {
|
||||
final GlobalKey<SfPdfViewerState> _pdfViewerKey = GlobalKey();
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return SfPdfViewer.asset(
|
||||
'assets/files/tangheem.pdf',
|
||||
key: _pdfViewerKey,
|
||||
canShowScrollHead: false,
|
||||
enableTextSelection: false,
|
||||
enableDocumentLinkAnnotation: false,
|
||||
canShowPaginationDialog: false,
|
||||
canShowScrollStatus: false,
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue