reworked page layout inheritence
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
import 'package:anyway/constants.dart';
|
||||
import 'package:anyway/main.dart';
|
||||
import 'package:anyway/structs/trip.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cached_network_image/cached_network_image.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import 'package:anyway/constants.dart';
|
||||
|
||||
import 'package:anyway/main.dart';
|
||||
import 'package:anyway/structs/trip.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
import 'package:anyway/structs/landmark.dart';
|
||||
|
||||
|
||||
|
||||
class LandmarkCard extends StatefulWidget {
|
||||
final Landmark landmark;
|
||||
final Trip parentTrip;
|
||||
@@ -23,20 +26,11 @@ class LandmarkCard extends StatefulWidget {
|
||||
|
||||
class _LandmarkCardState extends State<LandmarkCard> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
if (widget.landmark.type == typeStart || widget.landmark.type == typeFinish) {
|
||||
return TextButton.icon(
|
||||
onPressed: () {},
|
||||
icon: widget.landmark.type.icon,
|
||||
label: Text(widget.landmark.name),
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: 50,
|
||||
maxHeight: 200,
|
||||
// express the max height in terms text lines
|
||||
maxHeight: 7 * (Theme.of(context).textTheme.titleMedium!.fontSize! + 10),
|
||||
),
|
||||
child: Card(
|
||||
shape: RoundedRectangleBorder(
|
||||
@@ -79,23 +73,23 @@ class _LandmarkCardState extends State<LandmarkCard> {
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
Container(
|
||||
color: PRIMARY_COLOR,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Icon(widget.landmark.type.icon.icon, size: 16),
|
||||
Text(widget.landmark.type.name, style: TextStyle(fontWeight: FontWeight.bold)),
|
||||
],
|
||||
if (widget.landmark.type != typeStart && widget.landmark.type != typeFinish)
|
||||
Container(
|
||||
color: PRIMARY_COLOR,
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(5),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
spacing: 5,
|
||||
children: [
|
||||
Icon(Icons.timer_outlined, size: 16),
|
||||
Text("${widget.landmark.duration?.inMinutes} minutes"),
|
||||
],
|
||||
)
|
||||
)
|
||||
)
|
||||
),
|
||||
)
|
||||
),
|
||||
)
|
||||
],
|
||||
)
|
||||
),
|
||||
@@ -133,12 +127,6 @@ class _LandmarkCardState extends State<LandmarkCard> {
|
||||
// show the type, the website, and the wikipedia link as buttons/labels in a row
|
||||
children: [
|
||||
doneToggleButton(),
|
||||
// if (widget.landmark.duration != null && widget.landmark.duration!.inMinutes > 0)
|
||||
// TextButton.icon(
|
||||
// onPressed: () {},
|
||||
// icon: Icon(Icons.hourglass_bottom),
|
||||
// label: Text('${widget.landmark.duration!.inMinutes} minutes'),
|
||||
// ),
|
||||
if (widget.landmark.websiteURL != null)
|
||||
websiteButton(),
|
||||
|
||||
@@ -172,33 +160,35 @@ class _LandmarkCardState extends State<LandmarkCard> {
|
||||
// open a browser with the website link
|
||||
await launchUrl(Uri.parse(widget.landmark.websiteURL!));
|
||||
},
|
||||
icon: Icon(Icons.link),
|
||||
label: Text('Website'),
|
||||
icon: const Icon(Icons.link),
|
||||
label: const Text('Website'),
|
||||
);
|
||||
|
||||
|
||||
Widget optionsButton () => PopupMenuButton(
|
||||
icon: Icon(Icons.settings),
|
||||
icon: const Icon(Icons.settings),
|
||||
style: TextButtonTheme.of(context).style,
|
||||
itemBuilder: (context) => [
|
||||
PopupMenuItem(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.delete),
|
||||
title: Text('Delete'),
|
||||
leading: const Icon(Icons.delete),
|
||||
title: const Text('Delete'),
|
||||
onTap: () async {
|
||||
widget.parentTrip.removeLandmark(widget.landmark);
|
||||
rootScaffoldMessengerKey.currentState!.showSnackBar(
|
||||
SnackBar(content: Text("We won't show ${widget.landmark.name} again"))
|
||||
SnackBar(content: Text("${widget.landmark.name} won't be shown again"))
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
PopupMenuItem(
|
||||
child: ListTile(
|
||||
leading: Icon(Icons.star),
|
||||
title: Text('Favorite'),
|
||||
leading: const Icon(Icons.star),
|
||||
title: const Text('Favorite'),
|
||||
onTap: () async {
|
||||
// delete the landmark
|
||||
// await deleteLandmark(widget.landmark);
|
||||
rootScaffoldMessengerKey.currentState!.showSnackBar(
|
||||
SnackBar(content: Text("Not implemented yet"))
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
|
Reference in New Issue
Block a user