From b1a90b1e05c4d7f1e64c83bd624d4f018282fcfc Mon Sep 17 00:00:00 2001 From: Andreas Fahrecker Date: Thu, 18 Mar 2021 17:20:09 +0100 Subject: [PATCH] Added tpId parameter to Detail Screen List Item in cupertino now acceptable Signed-off-by: Andreas Fahrecker --- lib/ui/progress/progress_list_item.dart | 53 ++++++++++++++++++---- lib/ui/screens/progress_detail_screen.dart | 18 +++----- lib/utils/theme_utils.dart | 5 +- 3 files changed, 53 insertions(+), 23 deletions(-) diff --git a/lib/ui/progress/progress_list_item.dart b/lib/ui/progress/progress_list_item.dart index 84ad019..a8c7814 100644 --- a/lib/ui/progress/progress_list_item.dart +++ b/lib/ui/progress/progress_list_item.dart @@ -31,22 +31,45 @@ class ProgressListItem extends StatelessWidget { @override Widget build(BuildContext context) { - void _onTileTap() => - Navigator.pushNamed(context, ProgressDetailScreen.routeName, - arguments: ProgressDetailScreenArguments(timeProgress.id)); - Text _renderTitle(bool material) => Text( - timeProgress.name, - style: material ? null : cupertinoCardTextStyle, + void _onTileTap() => Navigator.push( + context, + platformPageRoute( + context: context, + builder: (context) => ProgressDetailScreen( + tpId: timeProgress.id, + )), ); - Widget _renderSubtitle() { + Widget _renderTitle(bool material) { + Text name = Text( + timeProgress.name, + style: material ? null : cupertinoCardTitleStyle, + textAlign: material ? null : TextAlign.left, + ); + Text duration = Text( + "${timeProgress.allDays()} Days", + style: material ? null : cupertinoCardSubtitleStyle, + textAlign: material ? null : TextAlign.left, + ); + Row title = Row( + children: [name, Spacer(), duration], + ); + if (!material) + return Padding( + padding: EdgeInsets.only(bottom: 16, right: 5), + child: title, + ); + return title; + } + + Widget _renderSubtitle(bool material) { if (!timeProgress.hasStarted()) return PlatformText( ProgressListTileStrings.startsInDaysString(timeProgress)); if (timeProgress.hasEnded()) return PlatformText( ProgressListTileStrings.endedDaysAgoString(timeProgress)); - return LinearPercentIndicator( + LinearPercentIndicator percentIndicator = LinearPercentIndicator( center: PlatformText(ProgressListTileStrings.percentString(timeProgress)), percent: timeProgress.percentDone(), @@ -54,6 +77,15 @@ class ProgressListItem extends StatelessWidget { backgroundColor: leftColor, lineHeight: 20, ); + if (!material) + return Padding( + padding: EdgeInsets.only( + bottom: 5, + right: 5, + ), + child: percentIndicator, + ); + return percentIndicator; } Widget _renderCupertino() { @@ -66,9 +98,10 @@ class ProgressListItem extends StatelessWidget { ), padding: EdgeInsets.fromLTRB(15, 15, 5, 5), child: Column( + crossAxisAlignment: CrossAxisAlignment.start, children: [ _renderTitle(false), - _renderSubtitle(), + _renderSubtitle(false), ], ), ), @@ -78,7 +111,7 @@ class ProgressListItem extends StatelessWidget { Widget _renderMaterial() { return ListTile( title: _renderTitle(true), - subtitle: _renderSubtitle(), + subtitle: _renderSubtitle(true), onTap: _onTileTap, ); } diff --git a/lib/ui/screens/progress_detail_screen.dart b/lib/ui/screens/progress_detail_screen.dart index 6e79176..2dc9ce3 100644 --- a/lib/ui/screens/progress_detail_screen.dart +++ b/lib/ui/screens/progress_detail_screen.dart @@ -7,16 +7,13 @@ import 'package:time_progress_tracker/ui/detail_screen_floating_action_buttons.d import 'package:time_progress_tracker/ui/progress/progress_editor_widget.dart'; import 'package:time_progress_tracker/ui/progress/progress_view_widget.dart'; -class ProgressDetailScreenArguments { - final String id; - - ProgressDetailScreenArguments(this.id); -} - class ProgressDetailScreen extends StatefulWidget { - static const routeName = "/progress"; static const title = "Progress View"; + final String tpId; + + const ProgressDetailScreen({Key key, @required this.tpId}) : super(key: key); + @override State createState() { return _ProgressDetailScreenState(); @@ -76,9 +73,6 @@ class _ProgressDetailScreenState extends State { @override Widget build(BuildContext context) { - final ProgressDetailScreenArguments args = - ModalRoute.of(context).settings.arguments; - return Scaffold( appBar: AppBar( title: Text(ProgressDetailScreen.title), @@ -86,7 +80,7 @@ class _ProgressDetailScreenState extends State { body: SettingsStoreConnector( loadedBuilder: (context, settingsVm) { return TimeProgressStoreConnector( - timeProgressId: args.id, + timeProgressId: widget.tpId, loadedBuilder: (context, tpVm) { _initEditedProgress(tpVm.tp); return Container( @@ -100,7 +94,7 @@ class _ProgressDetailScreenState extends State { ), floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat, floatingActionButton: TimeProgressStoreConnector( - timeProgressId: args.id, + timeProgressId: widget.tpId, loadedBuilder: (context, tpVm) { void _saveEditedProgress() { tpVm.updateTimeProgress(_editedProgress); diff --git a/lib/utils/theme_utils.dart b/lib/utils/theme_utils.dart index 1036552..56fc863 100644 --- a/lib/utils/theme_utils.dart +++ b/lib/utils/theme_utils.dart @@ -17,5 +17,8 @@ final CupertinoThemeData cupertinoThemeData = CupertinoThemeData( scaffoldBackgroundColor: Colors.white, ); final toolbarTextStyle = TextStyle(color: Colors.white, fontSize: 16); -final cupertinoCardTextStyle = TextStyle(color: Colors.white); +final cupertinoCardTitleStyle = + TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.w600); +final cupertinoCardSubtitleStyle = + TextStyle(color: Colors.grey, fontSize: 18, fontWeight: FontWeight.w400); final bottomTabsBackground = Colors.indigoAccent;