From 201ce6b8288f871cd09d5448da905a0980816ecd Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Tue, 30 Mar 2021 11:09:46 +0300 Subject: [PATCH] tangheem server changed to live server & improvements. --- lib/classes/consts.dart | 3 +- lib/main.dart | 21 +- lib/ui/screens/surah_screen.dart | 1 - lib/ui/screens/tangheem_detail_screen.dart | 300 ++++++++++++++++++++ lib/ui/screens/tangheem_screen.dart | 307 ++++----------------- lib/widgets/aya_player_widget.dart | 16 +- lib/widgets/text_highlight_widget.dart | 4 +- 7 files changed, 384 insertions(+), 268 deletions(-) create mode 100644 lib/ui/screens/tangheem_detail_screen.dart diff --git a/lib/classes/consts.dart b/lib/classes/consts.dart index 224df3b..c61e47b 100644 --- a/lib/classes/consts.dart +++ b/lib/classes/consts.dart @@ -1,5 +1,6 @@ class ApiConsts { - static String baseUrl = "http://10.200.204.20:2801/"; // Local server + //static String baseUrl = "http://10.200.204.20:2801/"; // Local server + static String baseUrl = "https://api.cssynapses.com/tangheem/"; // Live server static String authentication = baseUrl + "api/Authentication/"; static String tangheemUsers = baseUrl + "api/TangheemUsers/"; static String user = baseUrl + "api/User/"; diff --git a/lib/main.dart b/lib/main.dart index ec5764c..82dbef8 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -2,15 +2,15 @@ import 'dart:io'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:tangheem/ui/common_appbar.dart'; -import 'package:tangheem/ui/screens/forgot_password_screen.dart'; -import 'package:tangheem/ui/screens/home_screen.dart'; -import 'package:tangheem/ui/screens/login_screen.dart'; -import 'package:tangheem/ui/screens/registration_screen.dart'; -import 'package:tangheem/ui/screens/surah_screen.dart'; -import 'package:tangheem/ui/screens/tangheem_screen.dart'; - +import 'ui/common_appbar.dart'; +import 'ui/screens/forgot_password_screen.dart'; +import 'ui/screens/home_screen.dart'; +import 'ui/screens/login_screen.dart'; +import 'ui/screens/registration_screen.dart'; +import 'ui/screens/surah_screen.dart'; +import 'ui/screens/tangheem_detail_screen.dart'; import 'classes/colors.dart'; +import 'ui/screens/tangheem_screen.dart'; void main() { runApp(Application()); @@ -48,6 +48,11 @@ class Application extends StatelessWidget { ), ); break; + case TangheemDetailScreen.routeName: + className = CommonAppbar( + child: TangheemDetailScreen(ayatTangheemTypeMappedData: settings.arguments), + ); + break; case SurahScreen.routeName: String query = settings.arguments.toString(); className = CommonAppbar(child: SurahScreen(query: query)); diff --git a/lib/ui/screens/surah_screen.dart b/lib/ui/screens/surah_screen.dart index 903d37a..be4164d 100644 --- a/lib/ui/screens/surah_screen.dart +++ b/lib/ui/screens/surah_screen.dart @@ -11,7 +11,6 @@ import 'package:tangheem/widgets/auto_scroll_view/aya_scroll_view.dart'; import 'package:tangheem/widgets/auto_scroll_view/scroll_id.dart'; import 'package:tangheem/widgets/aya_player_widget.dart'; import 'package:tangheem/widgets/common_dropdown_button.dart'; -import 'package:tangheem/widgets/text_highlight_widget.dart'; class SurahScreen extends StatefulWidget { static const String routeName = "/surah"; diff --git a/lib/ui/screens/tangheem_detail_screen.dart b/lib/ui/screens/tangheem_detail_screen.dart new file mode 100644 index 0000000..a24af0a --- /dev/null +++ b/lib/ui/screens/tangheem_detail_screen.dart @@ -0,0 +1,300 @@ +import 'package:flutter/cupertino.dart'; +import 'package:flutter/material.dart'; +import 'package:flutter_svg/flutter_svg.dart'; +import 'package:tangheem/classes/colors.dart'; +import 'package:tangheem/models/aya_tangheem_type_mapped.dart'; +import 'package:tangheem/widgets/aya_player_widget.dart'; +import 'package:tangheem/widgets/text_highlight_widget.dart'; + +class TangheemDetailScreen extends StatefulWidget { + static const String routeName = "/tangheem_detail"; + final AyatTangheemTypeMappedData ayatTangheemTypeMappedData; + TangheemDetailScreen({Key key, this.ayatTangheemTypeMappedData}) : super(key: key); + + @override + _TangheemDetailScreenState createState() { + return _TangheemDetailScreenState(); + } +} + +class _TangheemDetailScreenState extends State { + GlobalKey _globalKey = GlobalKey(); + List _tangheemInsideTableTrueList = []; + List _tangheemInsideTableValueList = []; + List _tangheemInsideTableEmptyList = []; + List _tangheemWords = []; + + int _currentTangheemPage = -1; + AyatTangheemTypeMapped _ayatTangheemTypeMapped; + AyatTangheemTypeMappedData _ayatTangheemTypeMappedData; + + @override + void initState() { + super.initState(); + _tangheemInsideTableValueList = []; + _tangheemInsideTableEmptyList = []; + filterData(); + } + + // void getTangheemData() async { + // Utils.showLoading(context); + // try { + // _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah.surahID, widget.tangheemTypeName); + // if (_ayatTangheemTypeMapped.data.length > 0) _currentTangheemPage = 0; + // } catch (ex, tr) { + // Utils.handleException(ex, null); + // } finally { + // Utils.hideLoading(context); + // } + // filterData(); + // } + + void filterData() { + _ayatTangheemTypeMappedData = widget.ayatTangheemTypeMappedData; + _tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? ""); + _tangheemInsideTableTrueList = _ayatTangheemTypeMappedData?.property?.where((element) => element.isInsideTable)?.toList() ?? []; + _tangheemInsideTableValueList = _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; + _tangheemInsideTableEmptyList = _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isEmpty)?.toList() ?? []; + } + + @override + void dispose() { + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Container( + padding: EdgeInsets.fromLTRB(16, 24, 16, 0), + width: double.infinity, + child: _ayatTangheemTypeMappedData == null + ? SizedBox() + : Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + _ayatTangheemTypeMappedData.tangheemTypeName ?? "", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1.5), + ), + SizedBox(height: 8), + Text( + "هنا نضع\" تعريف بالاستفهام وتداخل الأساليب\"", + style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1), + ), + SizedBox(height: 8), + Expanded( + child: Container( + margin: EdgeInsets.only(top: 4, bottom: 4), + padding: EdgeInsets.only(top: 8, bottom: 8, right: 4, left: 4), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(8), + ), + child: Column( + children: [ + Expanded( + child: SingleChildScrollView( + physics: BouncingScrollPhysics(), + child: RepaintBoundary( + key: _globalKey, + child: Material( + color: Colors.white, + child: ListView( + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + padding: EdgeInsets.all(4), + children: [ + TextHighLightWidget( + text: _ayatTangheemTypeMappedData.ayahText ?? "", + valueColor: ColorConsts.primaryBlue, + highlights: _tangheemWords, + style: TextStyle( + fontFamily: "UthmanicHafs", + fontSize: 18, + fontWeight: FontWeight.bold, + ), + ), + SizedBox(height: 16), + ListView.separated( + itemCount: _tangheemInsideTableValueList.length, + physics: NeverScrollableScrollPhysics(), + shrinkWrap: true, + separatorBuilder: (context, index) { + return Divider( + color: Colors.white, + height: 1, + thickness: 0, + ); + }, + itemBuilder: (context, index) { + return Row( + children: [ + Expanded( + child: Container( + height: 40, + padding: EdgeInsets.only(left: 4, right: 8), + alignment: Alignment.centerRight, + child: Text( + _tangheemInsideTableValueList[index].propertyText, + style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange), + ), + color: ColorConsts.secondaryWhite, + ), + ), + SizedBox(width: 8), + Expanded( + child: Container( + height: 40, + padding: EdgeInsets.only(left: 4, right: 8), + alignment: Alignment.centerRight, + child: Text( + _tangheemInsideTableValueList[index].propertyValue, + style: TextStyle(color: ColorConsts.primaryBlack), + ), + color: ColorConsts.secondaryWhite, + ), + ) + ], + ); + }), + if (_tangheemInsideTableTrueList.isNotEmpty) + Container( + color: ColorConsts.primaryBlue, + margin: EdgeInsets.only(top: 8, bottom: 8), + padding: EdgeInsets.all(8), + child: Column( + children: [ + Text( + _ayatTangheemTypeMappedData.tangheemTypeName ?? "", + style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white), + ), + SizedBox(height: 8), + tangheemPropertyView(_tangheemInsideTableTrueList) + ], + ), + ), + tangheemPropertyView(_tangheemInsideTableEmptyList) + ], + ), + ), + ), + ), + ), + // SizedBox(height: 4), + // Padding( + // padding: EdgeInsets.only(left: 4, right: 4), + // child: Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + // children: [ + // nextOptionButton( + // "assets/icons/prev_single.svg", + // "الآيات السابقة", + // (_currentTangheemPage == 0 || (_ayatTangheemTypeMapped.data.length < 1)) + // ? null + // : () { + // _currentTangheemPage = _currentTangheemPage - 1; + // filterData(); + // }),سكندر + // previousOptionButton( + // "assets/icons/next_single.svg", + // "الآيات التالية", + // (_currentTangheemPage == (_ayatTangheemTypeMapped.data.length - 1) || (_ayatTangheemTypeMapped.data.length < 1)) + // ? null + // : () { + // _currentTangheemPage = _currentTangheemPage + 1; + // filterData(); + // }), + // ], + // ), + // ), + ], + ), + ), + ), + AyaPlayerWidget(surahName: _ayatTangheemTypeMappedData.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: _ayatTangheemTypeMappedData.voiceNote ?? []) + ], + ), + ); + } + + Widget nextOptionButton(String icon, String text, VoidCallback onPressed) { + return InkWell( + onTap: onPressed, + child: onPressed == null + ? SizedBox() + : Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + SvgPicture.asset(icon, height: 12, width: 12), + SizedBox(width: 4), + Text( + text, + style: TextStyle(color: ColorConsts.textGrey), + ), + ], + ), + ); + } + + Widget previousOptionButton(String icon, String text, VoidCallback onPressed) { + return InkWell( + onTap: onPressed, + child: onPressed == null + ? SizedBox() + : Row( + crossAxisAlignment: CrossAxisAlignment.center, + mainAxisSize: MainAxisSize.min, + children: [ + Text( + text, + style: TextStyle(color: ColorConsts.textGrey), + ), + SizedBox(width: 4), + SvgPicture.asset(icon, height: 12, width: 12), + ], + ), + ); + } + + Widget tangheemPropertyView(List tangheemPropertyList) { + return Container( + color: Colors.white, + child: ListView.separated( + itemCount: tangheemPropertyList.length, + physics: NeverScrollableScrollPhysics(), + padding: EdgeInsets.zero, + shrinkWrap: true, + separatorBuilder: (context, index) { + return Divider( + color: Colors.white, + height: 1, + thickness: 0, + ); + }, + itemBuilder: (context, index) { + return Container( + color: ColorConsts.secondaryWhite, + padding: EdgeInsets.all(8), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Text( + tangheemPropertyList[index].propertyText ?? "", + style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12, color: ColorConsts.secondaryOrange), + ), + SizedBox(height: 4), + Text( + tangheemPropertyList[index].propertyValue ?? "", + style: TextStyle(fontSize: 12, color: ColorConsts.secondaryPink), + ), + ], + ), + ); + }, + ), + ); + } +} diff --git a/lib/ui/screens/tangheem_screen.dart b/lib/ui/screens/tangheem_screen.dart index 7232dc4..0b90225 100644 --- a/lib/ui/screens/tangheem_screen.dart +++ b/lib/ui/screens/tangheem_screen.dart @@ -1,15 +1,11 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_svg/flutter_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/aya_model.dart'; -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/surah_model.dart'; -import 'package:tangheem/widgets/aya_player_widget.dart'; +import 'package:tangheem/ui/screens/tangheem_detail_screen.dart'; import 'package:tangheem/widgets/text_highlight_widget.dart'; class TangheemScreen extends StatefulWidget { @@ -25,44 +21,23 @@ class TangheemScreen extends StatefulWidget { } class _TangheemScreenState extends State { - GlobalKey _globalKey = GlobalKey(); - List _tangheemInsideTableTrueList = []; - List _tangheemInsideTableValueList = []; - List _tangheemInsideTableEmptyList = []; - List _tangheemWords = []; - - int _currentTangheemPage = -1; AyatTangheemTypeMapped _ayatTangheemTypeMapped; - AyatTangheemTypeMappedData _ayatTangheemTypeMappedData; @override void initState() { super.initState(); - _tangheemInsideTableValueList = []; - _tangheemInsideTableEmptyList = []; getTangheemData(); } void getTangheemData() async { Utils.showLoading(context); try { - _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(0, widget.tangheemTypeName); - if (_ayatTangheemTypeMapped.data.length > 0) _currentTangheemPage = 0; + _ayatTangheemTypeMapped = await TangheemUserApiClient().getAyaTangheemTypeMapped(widget.surah.surahID, widget.tangheemTypeName); } catch (ex, tr) { Utils.handleException(ex, null); } finally { Utils.hideLoading(context); } - filterData(); - } - - void filterData() { - _ayatTangheemTypeMappedData = _ayatTangheemTypeMapped.data[_currentTangheemPage]; - _tangheemWords.add(_ayatTangheemTypeMappedData.highlightText ?? ""); - _tangheemInsideTableTrueList = _ayatTangheemTypeMappedData?.property?.where((element) => element.isInsideTable)?.toList() ?? []; - _tangheemInsideTableValueList = _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isNotEmpty)?.toList() ?? []; - _tangheemInsideTableEmptyList = _ayatTangheemTypeMappedData?.property?.where((element) => (!element.isInsideTable) && (element.propertyValue ?? "").isEmpty)?.toList() ?? []; - setState(() {}); } @@ -73,237 +48,63 @@ class _TangheemScreenState extends State { @override Widget build(BuildContext context) { - return Container( - padding: EdgeInsets.fromLTRB(16, 24, 16, 0), - width: double.infinity, - child: _ayatTangheemTypeMappedData == null - ? SizedBox() - : Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Text( - widget.tangheemTypeName ?? "", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 20, color: ColorConsts.primaryBlue, height: 1.5), - ), - SizedBox(height: 8), - Text( - "هنا نضع\" تعريف بالاستفهام وتداخل الأساليب\"", - style: TextStyle(fontSize: 14, color: ColorConsts.textGrey, height: 1), - ), - SizedBox(height: 8), - Expanded( - child: Container( - margin: EdgeInsets.only(top: 4, bottom: 4), - padding: EdgeInsets.only(top: 8, bottom: 8, right: 4, left: 4), - decoration: BoxDecoration( - color: Colors.white, - borderRadius: BorderRadius.circular(8), - ), - child: Column( - children: [ - Expanded( - child: SingleChildScrollView( - physics: BouncingScrollPhysics(), - child: RepaintBoundary( - key: _globalKey, - child: Material( - color: Colors.white, - child: ListView( - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - padding: EdgeInsets.all(4), - children: [ - TextHighLightWidget( - text: _ayatTangheemTypeMappedData.ayahText ?? "", - valueColor: ColorConsts.primaryBlue, - highlights: _tangheemWords, - style: TextStyle( - fontFamily: "UthmanicHafs", - fontSize: 18, - fontWeight: FontWeight.bold, - ), - ), - SizedBox(height: 16), - ListView.separated( - itemCount: _tangheemInsideTableValueList.length, - physics: NeverScrollableScrollPhysics(), - shrinkWrap: true, - separatorBuilder: (context, index) { - return Divider( - color: Colors.white, - height: 1, - thickness: 0, - ); - }, - itemBuilder: (context, index) { - return Row( - children: [ - Expanded( - child: Container( - height: 40, - padding: EdgeInsets.only(left: 4, right: 8), - alignment: Alignment.centerRight, - child: Text( - _tangheemInsideTableValueList[index].propertyText, - style: TextStyle(fontWeight: FontWeight.bold, color: ColorConsts.secondaryOrange), - ), - color: ColorConsts.secondaryWhite, - ), - ), - SizedBox(width: 8), - Expanded( - child: Container( - height: 40, - padding: EdgeInsets.only(left: 4, right: 8), - alignment: Alignment.centerRight, - child: Text( - _tangheemInsideTableValueList[index].propertyValue, - style: TextStyle(color: ColorConsts.primaryBlack), - ), - color: ColorConsts.secondaryWhite, - ), - ) - ], - ); - }), - if (_tangheemInsideTableTrueList.isNotEmpty) - Container( - color: ColorConsts.primaryBlue, - margin: EdgeInsets.only(top: 8, bottom: 8), - padding: EdgeInsets.all(8), - child: Column( - children: [ - Text( - widget.tangheemTypeName ?? "", - style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white), - ), - SizedBox(height: 8), - tangheemPropertyView(_tangheemInsideTableTrueList) - ], - ), - ), - tangheemPropertyView(_tangheemInsideTableEmptyList) - ], - ), - ), - ), + var _dataList = _ayatTangheemTypeMapped?.data ?? []; + return _dataList.isEmpty + ? SizedBox() + : ListView.separated( + physics: BouncingScrollPhysics(), + padding: EdgeInsets.all(16), + itemCount: _dataList.length, + separatorBuilder: (context, index) { + return SizedBox(height: 8); + }, + itemBuilder: (context, index) { + return InkWell( + onTap: () { + Navigator.pushNamed(context, TangheemDetailScreen.routeName, arguments: _dataList[index]); + }, + borderRadius: BorderRadius.circular(4), + child: Container( + padding: EdgeInsets.fromLTRB(12, 8, 12, 8), + decoration: BoxDecoration( + color: Colors.white, + borderRadius: BorderRadius.circular(4), + ), + child: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Row( + mainAxisSize: MainAxisSize.min, + children: [ + Text( + _dataList[index].surahNameAr + ":", + style: TextStyle(fontSize: 12, color: ColorConsts.primaryBlue), ), - ), - SizedBox(height: 4), - Padding( - padding: EdgeInsets.only(left: 4, right: 4), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - nextOptionButton( - "assets/icons/prev_single.svg", - "الآيات السابقة", - (_currentTangheemPage == 0 || (_ayatTangheemTypeMapped.data.length < 1)) - ? null - : () { - _currentTangheemPage = _currentTangheemPage - 1; - filterData(); - }), - previousOptionButton( - "assets/icons/next_single.svg", - "الآيات التالية", - (_currentTangheemPage == (_ayatTangheemTypeMapped.data.length - 1) || (_ayatTangheemTypeMapped.data.length < 1)) - ? null - : () { - _currentTangheemPage = _currentTangheemPage + 1; - filterData(); - }), - ], + Text( + " ${_dataList[index].ayahNo}", + style: TextStyle(fontSize: 14, color: ColorConsts.secondaryOrange), ), + ], + ), + TextHighLightWidget( + text: _dataList[index].ayahText, + valueColor: ColorConsts.secondaryOrange, + highlights: [_dataList[index].highlightText], + textAlign: TextAlign.start, + style: TextStyle( + fontFamily: "UthmanicHafs", + fontSize: 16, + color: ColorConsts.primaryBlue, + fontWeight: FontWeight.bold, ), - ], - ), + ), + ], ), ), - AyaPlayerWidget(surahName: _ayatTangheemTypeMappedData.surahNameAr ?? "", globalKey: _globalKey, voiceNoteList: _ayatTangheemTypeMappedData.voiceNote ?? []) - ], - ), - ); - } - - Widget nextOptionButton(String icon, String text, VoidCallback onPressed) { - return InkWell( - onTap: onPressed, - child: onPressed == null - ? SizedBox() - : Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - SvgPicture.asset(icon, height: 12, width: 12), - SizedBox(width: 4), - Text( - text, - style: TextStyle(color: ColorConsts.textGrey), - ), - ], - ), - ); - } - - Widget previousOptionButton(String icon, String text, VoidCallback onPressed) { - return InkWell( - onTap: onPressed, - child: onPressed == null - ? SizedBox() - : Row( - crossAxisAlignment: CrossAxisAlignment.center, - mainAxisSize: MainAxisSize.min, - children: [ - Text( - text, - style: TextStyle(color: ColorConsts.textGrey), - ), - SizedBox(width: 4), - SvgPicture.asset(icon, height: 12, width: 12), - ], - ), - ); - } - - Widget tangheemPropertyView(List tangheemPropertyList) { - return Container( - color: Colors.white, - child: ListView.separated( - itemCount: tangheemPropertyList.length, - physics: NeverScrollableScrollPhysics(), - padding: EdgeInsets.zero, - shrinkWrap: true, - separatorBuilder: (context, index) { - return Divider( - color: Colors.white, - height: 1, - thickness: 0, - ); - }, - itemBuilder: (context, index) { - return Container( - color: ColorConsts.secondaryWhite, - padding: EdgeInsets.all(8), - child: Column( - mainAxisSize: MainAxisSize.min, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Text( - tangheemPropertyList[index].propertyText ?? "", - style: TextStyle(fontWeight: FontWeight.bold, fontSize: 12, color: ColorConsts.secondaryOrange), - ), - SizedBox(height: 4), - Text( - tangheemPropertyList[index].propertyValue ?? "", - style: TextStyle(fontSize: 12, color: ColorConsts.secondaryPink), - ), - ], - ), + ); + }, ); - }, - ), - ); } } diff --git a/lib/widgets/aya_player_widget.dart b/lib/widgets/aya_player_widget.dart index 11d5d8c..564f7cc 100644 --- a/lib/widgets/aya_player_widget.dart +++ b/lib/widgets/aya_player_widget.dart @@ -46,7 +46,7 @@ class _AyaPlayerWidgetState extends State { setAudioSource() { try { var voiceList = []; - if (widget.voiceNoteList != null && widget.voiceNoteList.length > 0) { + if ((widget.voiceNoteList?.length ?? 0) > 0) { voiceList = widget.voiceNoteList.map((e) => AudioSource.uri(Uri.parse(e.exposeFilePath))).toList(); _currentVoiceNote = 0; } @@ -55,8 +55,10 @@ class _AyaPlayerWidgetState extends State { _isAudioHaveError = true; }); } catch (e) { + print(e); _isAudioHaveError = true; } + print(_player.currentIndex); } @override @@ -119,9 +121,15 @@ class _AyaPlayerWidgetState extends State { style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14, color: ColorConsts.primaryBlack, height: 1), ), SizedBox(height: 4), - Text( - _currentVoiceNote < 1 ? "" : widget.voiceNoteList[_currentVoiceNote], - style: TextStyle(fontSize: 10, color: ColorConsts.textGrey1, height: 1), + StreamBuilder( + stream: _player.currentIndexStream, + builder: (context, snapshot) { + final state = snapshot.data; + return Text( + state == null ? "" : widget.voiceNoteList[state].userName, + style: TextStyle(fontSize: 10, color: ColorConsts.textGrey1, height: 1), + ); + }, ), ], ), diff --git a/lib/widgets/text_highlight_widget.dart b/lib/widgets/text_highlight_widget.dart index 8a90d1e..6df5211 100644 --- a/lib/widgets/text_highlight_widget.dart +++ b/lib/widgets/text_highlight_widget.dart @@ -8,11 +8,13 @@ class TextHighLightWidget extends StatelessWidget { final Color valueColor; final List highlights; final TextStyle style; + final TextAlign textAlign; final Color highLightColor = ColorConsts.secondaryOrange; TextHighLightWidget({ Key key, this.text, + this.textAlign = TextAlign.center, this.valueText, this.valueColor, this.highlights, @@ -115,6 +117,6 @@ class TextHighLightWidget extends StatelessWidget { } RichText _richText(TextSpan text) { - return RichText(key: key, text: text, textAlign: TextAlign.center); + return RichText(key: key, text: text, textAlign: textAlign); } }