Added tpId parameter to Detail Screen
List Item in cupertino now acceptable Signed-off-by: Andreas Fahrecker <AndreasFahrecker@gmail.com>
This commit is contained in:
parent
e71b65bdf3
commit
b1a90b1e05
@ -31,22 +31,45 @@ class ProgressListItem extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
void _onTileTap() =>
|
void _onTileTap() => Navigator.push(
|
||||||
Navigator.pushNamed(context, ProgressDetailScreen.routeName,
|
context,
|
||||||
arguments: ProgressDetailScreenArguments(timeProgress.id));
|
platformPageRoute(
|
||||||
Text _renderTitle(bool material) => Text(
|
context: context,
|
||||||
timeProgress.name,
|
builder: (context) => ProgressDetailScreen(
|
||||||
style: material ? null : cupertinoCardTextStyle,
|
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())
|
if (!timeProgress.hasStarted())
|
||||||
return PlatformText(
|
return PlatformText(
|
||||||
ProgressListTileStrings.startsInDaysString(timeProgress));
|
ProgressListTileStrings.startsInDaysString(timeProgress));
|
||||||
if (timeProgress.hasEnded())
|
if (timeProgress.hasEnded())
|
||||||
return PlatformText(
|
return PlatformText(
|
||||||
ProgressListTileStrings.endedDaysAgoString(timeProgress));
|
ProgressListTileStrings.endedDaysAgoString(timeProgress));
|
||||||
return LinearPercentIndicator(
|
LinearPercentIndicator percentIndicator = LinearPercentIndicator(
|
||||||
center:
|
center:
|
||||||
PlatformText(ProgressListTileStrings.percentString(timeProgress)),
|
PlatformText(ProgressListTileStrings.percentString(timeProgress)),
|
||||||
percent: timeProgress.percentDone(),
|
percent: timeProgress.percentDone(),
|
||||||
@ -54,6 +77,15 @@ class ProgressListItem extends StatelessWidget {
|
|||||||
backgroundColor: leftColor,
|
backgroundColor: leftColor,
|
||||||
lineHeight: 20,
|
lineHeight: 20,
|
||||||
);
|
);
|
||||||
|
if (!material)
|
||||||
|
return Padding(
|
||||||
|
padding: EdgeInsets.only(
|
||||||
|
bottom: 5,
|
||||||
|
right: 5,
|
||||||
|
),
|
||||||
|
child: percentIndicator,
|
||||||
|
);
|
||||||
|
return percentIndicator;
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget _renderCupertino() {
|
Widget _renderCupertino() {
|
||||||
@ -66,9 +98,10 @@ class ProgressListItem extends StatelessWidget {
|
|||||||
),
|
),
|
||||||
padding: EdgeInsets.fromLTRB(15, 15, 5, 5),
|
padding: EdgeInsets.fromLTRB(15, 15, 5, 5),
|
||||||
child: Column(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_renderTitle(false),
|
_renderTitle(false),
|
||||||
_renderSubtitle(),
|
_renderSubtitle(false),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@ -78,7 +111,7 @@ class ProgressListItem extends StatelessWidget {
|
|||||||
Widget _renderMaterial() {
|
Widget _renderMaterial() {
|
||||||
return ListTile(
|
return ListTile(
|
||||||
title: _renderTitle(true),
|
title: _renderTitle(true),
|
||||||
subtitle: _renderSubtitle(),
|
subtitle: _renderSubtitle(true),
|
||||||
onTap: _onTileTap,
|
onTap: _onTileTap,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -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_editor_widget.dart';
|
||||||
import 'package:time_progress_tracker/ui/progress/progress_view_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 {
|
class ProgressDetailScreen extends StatefulWidget {
|
||||||
static const routeName = "/progress";
|
|
||||||
static const title = "Progress View";
|
static const title = "Progress View";
|
||||||
|
|
||||||
|
final String tpId;
|
||||||
|
|
||||||
|
const ProgressDetailScreen({Key key, @required this.tpId}) : super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
State<StatefulWidget> createState() {
|
State<StatefulWidget> createState() {
|
||||||
return _ProgressDetailScreenState();
|
return _ProgressDetailScreenState();
|
||||||
@ -76,9 +73,6 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final ProgressDetailScreenArguments args =
|
|
||||||
ModalRoute.of(context).settings.arguments;
|
|
||||||
|
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(
|
appBar: AppBar(
|
||||||
title: Text(ProgressDetailScreen.title),
|
title: Text(ProgressDetailScreen.title),
|
||||||
@ -86,7 +80,7 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
body: SettingsStoreConnector(
|
body: SettingsStoreConnector(
|
||||||
loadedBuilder: (context, settingsVm) {
|
loadedBuilder: (context, settingsVm) {
|
||||||
return TimeProgressStoreConnector(
|
return TimeProgressStoreConnector(
|
||||||
timeProgressId: args.id,
|
timeProgressId: widget.tpId,
|
||||||
loadedBuilder: (context, tpVm) {
|
loadedBuilder: (context, tpVm) {
|
||||||
_initEditedProgress(tpVm.tp);
|
_initEditedProgress(tpVm.tp);
|
||||||
return Container(
|
return Container(
|
||||||
@ -100,7 +94,7 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
|||||||
),
|
),
|
||||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||||
floatingActionButton: TimeProgressStoreConnector(
|
floatingActionButton: TimeProgressStoreConnector(
|
||||||
timeProgressId: args.id,
|
timeProgressId: widget.tpId,
|
||||||
loadedBuilder: (context, tpVm) {
|
loadedBuilder: (context, tpVm) {
|
||||||
void _saveEditedProgress() {
|
void _saveEditedProgress() {
|
||||||
tpVm.updateTimeProgress(_editedProgress);
|
tpVm.updateTimeProgress(_editedProgress);
|
||||||
|
@ -17,5 +17,8 @@ final CupertinoThemeData cupertinoThemeData = CupertinoThemeData(
|
|||||||
scaffoldBackgroundColor: Colors.white,
|
scaffoldBackgroundColor: Colors.white,
|
||||||
);
|
);
|
||||||
final toolbarTextStyle = TextStyle(color: Colors.white, fontSize: 16);
|
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;
|
final bottomTabsBackground = Colors.indigoAccent;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user