diff --git a/assets/files/tangheem.pdf b/assets/files/tangheem.pdf new file mode 100644 index 0000000..ea8b42d Binary files /dev/null and b/assets/files/tangheem.pdf differ diff --git a/lib/api/tangheem_user_api_client.dart b/lib/api/tangheem_user_api_client.dart index 9e2c3a3..fd55bd2 100644 --- a/lib/api/tangheem_user_api_client.dart +++ b/lib/api/tangheem_user_api_client.dart @@ -3,6 +3,7 @@ import 'dart:async'; import 'package:tangheem/models/aya_tangheem_property.dart'; import 'package:tangheem/models/aya_tangheem_type.dart'; import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; +import 'package:tangheem/models/content_info_model.dart'; import 'package:tangheem/models/country_model.dart'; import 'package:tangheem/models/discussion_model.dart'; import 'package:tangheem/models/general_response_model.dart'; @@ -126,4 +127,10 @@ class TangheemUserApiClient { var postParams = {}; return await ApiClient().postJsonForObject((json) => MemberModel.fromJson(json), url, postParams); } + + Future getContentInfo(int contentId) async { + String url = "${ApiConsts.tangheemUsers}ContentInfo_Get"; + var postParams = {"contentTypeId": contentId}; + return await ApiClient().postJsonForObject((json) => ContentInfoModel.fromJson(json), url, postParams); + } } diff --git a/lib/app_state/app_state.dart b/lib/app_state/app_state.dart index 8716f48..0b6b918 100644 --- a/lib/app_state/app_state.dart +++ b/lib/app_state/app_state.dart @@ -1,3 +1,4 @@ +import 'package:tangheem/models/content_info_model.dart'; import 'package:tangheem/models/navigation_model.dart'; import 'package:tangheem/models/surah_model.dart'; import 'package:tangheem/models/authentication_user_model.dart'; @@ -13,6 +14,12 @@ class AppState { this._surahModel = _surahModel; } + ContentInfoDataModel _copyRight; + ContentInfoDataModel get getContentInfoModel => _copyRight; + void setContentInfoModel(ContentInfoDataModel _copyRight) { + this._copyRight = _copyRight; + } + AuthenticationUserModel _authenticationUser; bool get isUserLogin => _authenticationUser != null; String get token => _authenticationUser?.result?.data?.token; diff --git a/lib/main.dart b/lib/main.dart index 3cb2a0d..75f075b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,7 +4,9 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:tangheem/ui/screens/bookmark_screen.dart'; import 'package:tangheem/ui/screens/contact_us_screen.dart'; +import 'package:tangheem/ui/screens/content_info_screen.dart'; import 'package:tangheem/ui/screens/member_screen.dart'; +import 'package:tangheem/ui/screens/pdf_viewer_screen.dart'; import 'ui/common_appbar.dart'; import 'ui/screens/forgot_password_screen.dart'; import 'ui/screens/home_screen.dart'; @@ -51,6 +53,13 @@ class Application extends StatelessWidget { case MemberScreen.routeName: className = CommonAppbar(child: MemberScreen()); break; + case PdfViewerScreen.routeName: + className = CommonAppbar(child: PdfViewerScreen()); + break; + case ContentInfoScreen.routeName: + var index = settings.arguments; + className = CommonAppbar(child: ContentInfoScreen(contentId: index)); + break; case TangheemScreen.routeName: Map data = settings.arguments; className = CommonAppbar( diff --git a/lib/models/content_info_model.dart b/lib/models/content_info_model.dart new file mode 100644 index 0000000..73ddd01 --- /dev/null +++ b/lib/models/content_info_model.dart @@ -0,0 +1,73 @@ +class ContentInfoModel { + int totalItemsCount; + int statusCode; + String message; + List data; + + ContentInfoModel( + {this.totalItemsCount, this.statusCode, this.message, this.data}); + + ContentInfoModel.fromJson(Map json) { + totalItemsCount = json['totalItemsCount']; + statusCode = json['statusCode']; + message = json['message']; + if (json['data'] != null) { + data = new List(); + json['data'].forEach((v) { + data.add(new ContentInfoDataModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = new Map(); + 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 json) { + contentInfoId = json['contentInfoId']; + contentTypeId = json['contentTypeId']; + content = json['content']; + contentTypeNameEn = json['contentTypeNameEn']; + contentTypeNameAr = json['contentTypeNameAr']; + fileName = json['fileName']; + exposeFilePath = json['exposeFilePath']; + } + + Map toJson() { + final Map data = new Map(); + 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; + } +} diff --git a/lib/models/navigation_model.dart b/lib/models/navigation_model.dart index 3c39208..631e897 100644 --- a/lib/models/navigation_model.dart +++ b/lib/models/navigation_model.dart @@ -38,6 +38,7 @@ class NavigationDataModel { String mobileNavigationUrl; String categoryName; String fontIcon; + String mobileFontIcon; int parentId; int orderNo; int roleId; @@ -49,6 +50,7 @@ class NavigationDataModel { this.mobileNavigationUrl, this.categoryName, this.fontIcon, + this.mobileFontIcon, this.parentId, this.orderNo, this.roleId}); @@ -60,6 +62,7 @@ class NavigationDataModel { mobileNavigationUrl = json['mobileNavigationUrl']; categoryName = json['categoryName']; fontIcon = json['fontIcon']; + mobileFontIcon = json['mobileFontIcon']; parentId = json['parentId']; orderNo = json['orderNo']; roleId = json['roleId']; @@ -73,6 +76,7 @@ class NavigationDataModel { data['mobileNavigationUrl'] = this.mobileNavigationUrl; data['categoryName'] = this.categoryName; data['fontIcon'] = this.fontIcon; + data['mobileFontIcon'] = this.mobileFontIcon; data['parentId'] = this.parentId; data['orderNo'] = this.orderNo; data['roleId'] = this.roleId; diff --git a/lib/ui/common_appbar.dart b/lib/ui/common_appbar.dart index 808e9df..1bb0cbe 100644 --- a/lib/ui/common_appbar.dart +++ b/lib/ui/common_appbar.dart @@ -6,10 +6,12 @@ import 'package:tangheem/app_state/app_state.dart'; import 'package:tangheem/classes/colors.dart'; import 'package:tangheem/classes/consts.dart'; import 'package:tangheem/classes/utils.dart'; +import 'package:tangheem/models/content_info_model.dart'; import 'package:tangheem/models/navigation_model.dart'; import 'package:tangheem/models/quick_links_model.dart'; import 'package:tangheem/ui/screens/bookmark_screen.dart'; import 'package:tangheem/ui/screens/contact_us_screen.dart'; +import 'package:tangheem/ui/screens/content_info_screen.dart'; import 'package:tangheem/ui/screens/login_screen.dart'; import 'package:tangheem/ui/screens/quran_screen.dart'; import 'package:url_launcher/url_launcher.dart'; @@ -31,6 +33,7 @@ class _CommonAppbarState extends State { final GlobalKey _scaffoldKey = new GlobalKey(); List quickLinks = []; List navigationList = []; + ContentInfoDataModel _copyRight; @override void initState() { @@ -38,6 +41,23 @@ class _CommonAppbarState extends State { getPrefs(); getNavigation(); getQuickLinks(); + getCopyRight(); + } + + void getCopyRight() async { + if (AppState().getContentInfoModel == null) { + try { + var model = await TangheemUserApiClient().getContentInfo(3); + var contentList = model?.data ?? []; + if (contentList.length > 0) { + _copyRight = contentList.first; + AppState().setContentInfoModel(_copyRight); + } + } catch (ex) {} + } else { + _copyRight = AppState().getContentInfoModel; + } + setState(() {}); } void getNavigation() async { @@ -191,32 +211,7 @@ class _CommonAppbarState extends State { padding: EdgeInsets.only(left: 24, right: 24), itemCount: navigationList.length, itemBuilder: (context, index) { - String icon = ""; - if (navigationList[index].navigationId == 5) { - icon = "assets/icons/home.svg"; - } - if (navigationList[index].navigationId == 6) { - icon = "assets/icons/encyclopedia.svg"; - } - if (navigationList[index].navigationId == 7) { - icon = "assets/icons/copyrights.svg"; - } - if (navigationList[index].navigationId == 8) { - icon = "assets/icons/about.svg"; - } - if (navigationList[index].navigationId == 9) { - icon = "assets/icons/browse.svg"; - } - if (navigationList[index].navigationId == 11) { - icon = "assets/icons/members.svg"; - } - if (navigationList[index].navigationId == 12) { - icon = "assets/icons/read_quran.svg"; - } - if (navigationList[index].navigationId == 13) { - icon = "assets/icons/contact.svg"; - } - + String icon = "assets/icons/${navigationList[index].mobileFontIcon}.svg"; if (navigationList[index].parentId == 1) { return myListItem(icon, navigationList[index].navigationText, navigationList[index].orderNo == 1 ? true : false, onTap: () { String url = navigationList[index]?.mobileNavigationUrl ?? ""; @@ -236,7 +231,16 @@ class _CommonAppbarState extends State { if (url.isEmpty) { return; } - Navigator.pushNamed(context, url, arguments: null); + var contentId; + if (navigationList[index].mobileNavigationUrl == "/introduction") { + url = ContentInfoScreen.routeName; + contentId = 2; + } else if (navigationList[index].mobileNavigationUrl == "/encyclopedia") { + url = ContentInfoScreen.routeName; + contentId = 1; + } + print("url:$url"); + Navigator.pushNamed(context, url, arguments: contentId); }), ), Container( @@ -250,118 +254,7 @@ class _CommonAppbarState extends State { ), ); } - }) - - // ListView( - // physics: BouncingScrollPhysics(), - // padding: EdgeInsets.only(left: 24, right: 24), - // children: [ - // // - // // for(int i=0;i { ], ), ), - Padding( - padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), - child: Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - "Powered by Cloud Solutions", - maxLines: 1, - textAlign: TextAlign.right, - style: TextStyle(fontSize: 14), - ), - SizedBox(width: 8), - SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30) - ], - ), - ) + if (_copyRight != null) + Padding( + padding: EdgeInsets.only(left: 32, right: 32, bottom: 8), + child: Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + _copyRight.content ?? "", + maxLines: 1, + textAlign: TextAlign.right, + style: TextStyle(fontSize: 14), + ), + SizedBox(width: 8), + Image.network(_copyRight.exposeFilePath, width: 30, height: 30) + //SvgPicture.asset("assets/logos/cloud_logo.svg", width: 30, height: 30) + ], + ), + ) ], ), ), diff --git a/lib/ui/screens/content_info_screen.dart b/lib/ui/screens/content_info_screen.dart new file mode 100644 index 0000000..7e08d32 --- /dev/null +++ b/lib/ui/screens/content_info_screen.dart @@ -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 { + List 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, + ); + }, + ); + } +} diff --git a/lib/ui/screens/pdf_viewer_screen.dart b/lib/ui/screens/pdf_viewer_screen.dart new file mode 100644 index 0000000..f94a5a0 --- /dev/null +++ b/lib/ui/screens/pdf_viewer_screen.dart @@ -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 { + final GlobalKey _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, + ); + } +} diff --git a/lib/ui/screens/quran_screen.dart b/lib/ui/screens/quran_screen.dart index 119208d..354daec 100644 --- a/lib/ui/screens/quran_screen.dart +++ b/lib/ui/screens/quran_screen.dart @@ -97,7 +97,9 @@ class _QuranScreenState extends State { List _bookMark = []; void getBookMark() async { _bookMark = await BookMarkModel.getFromPrefs(); - if (_bookMark.length > 1) { + if (_bookMark.length == 1) { + _selectedAyaForBookmark = _selectedAyaForBookmark ?? _bookMark.first; + } else if (_bookMark.length > 1) { _selectedAyaForBookmark = _selectedAyaForBookmark ?? _bookMark.last; } setState(() {}); diff --git a/pubspec.yaml b/pubspec.yaml index ac68590..94cbb58 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -40,6 +40,7 @@ dependencies: url_launcher: ^6.0.3 flutter_slidable: ^0.6.0 record_mp3: ^2.1.0 + syncfusion_flutter_pdfviewer: ^19.1.58-beta dev_dependencies: flutter_test: @@ -60,6 +61,7 @@ flutter: assets: - assets/icons/ - assets/logos/ + - assets/files/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware.