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
|
||||
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,
|
||||
);
|
||||
}
|
||||
|
@ -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<StatefulWidget> createState() {
|
||||
return _ProgressDetailScreenState();
|
||||
@ -76,9 +73,6 @@ class _ProgressDetailScreenState extends State<ProgressDetailScreen> {
|
||||
|
||||
@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<ProgressDetailScreen> {
|
||||
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<ProgressDetailScreen> {
|
||||
),
|
||||
floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
|
||||
floatingActionButton: TimeProgressStoreConnector(
|
||||
timeProgressId: args.id,
|
||||
timeProgressId: widget.tpId,
|
||||
loadedBuilder: (context, tpVm) {
|
||||
void _saveEditedProgress() {
|
||||
tpVm.updateTimeProgress(_editedProgress);
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user