mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-07-23 00:52:14 +00:00
100 lines
2.7 KiB
Dart
100 lines
2.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:go_router/go_router.dart';
|
|
|
|
// TODO(yijing): delete this after implementing the real screen inside bottom navigation bar.
|
|
/// For demonstration purposes
|
|
class DetailsPlaceholderScreen extends StatefulWidget {
|
|
/// Constructs a [DetailsScreen].
|
|
const DetailsPlaceholderScreen({
|
|
required this.label,
|
|
this.param,
|
|
this.extra,
|
|
this.withScaffold = true,
|
|
super.key,
|
|
});
|
|
|
|
/// The label to display in the center of the screen.
|
|
final String label;
|
|
|
|
/// Optional param
|
|
final String? param;
|
|
|
|
/// Optional extra object
|
|
final Object? extra;
|
|
|
|
/// Wrap in scaffold
|
|
final bool withScaffold;
|
|
|
|
@override
|
|
State<StatefulWidget> createState() => DetailsPlaceholderScreenState();
|
|
}
|
|
|
|
/// The state for DetailsScreen
|
|
class DetailsPlaceholderScreenState extends State<DetailsPlaceholderScreen> {
|
|
int _counter = 0;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
if (widget.withScaffold) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text('Details Screen - ${widget.label}'),
|
|
),
|
|
body: _build(context),
|
|
);
|
|
} else {
|
|
return Container(
|
|
color: Theme.of(context).scaffoldBackgroundColor,
|
|
child: _build(context),
|
|
);
|
|
}
|
|
}
|
|
|
|
Widget _build(BuildContext context) {
|
|
return Center(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
children: <Widget>[
|
|
Text(
|
|
'Details for ${widget.label} - Counter: $_counter',
|
|
style: Theme.of(context).textTheme.titleLarge,
|
|
),
|
|
const Padding(padding: EdgeInsets.all(4)),
|
|
TextButton(
|
|
onPressed: () {
|
|
setState(() {
|
|
_counter++;
|
|
});
|
|
},
|
|
child: const Text('Increment counter'),
|
|
),
|
|
const Padding(padding: EdgeInsets.all(8)),
|
|
if (widget.param != null)
|
|
Text(
|
|
'Parameter: ${widget.param!}',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
const Padding(padding: EdgeInsets.all(8)),
|
|
if (widget.extra != null)
|
|
Text(
|
|
'Extra: ${widget.extra!}',
|
|
style: Theme.of(context).textTheme.titleMedium,
|
|
),
|
|
if (!widget.withScaffold) ...<Widget>[
|
|
const Padding(padding: EdgeInsets.all(16)),
|
|
TextButton(
|
|
onPressed: () {
|
|
GoRouter.of(context).pop();
|
|
},
|
|
child: const Text(
|
|
'< Back',
|
|
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
|
|
),
|
|
),
|
|
]
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|