Move session thumbnail out of flexible sliver
This commit is contained in:
parent
65207e6e90
commit
dfa1c6e77a
2 changed files with 155 additions and 139 deletions
|
@ -1,4 +1,3 @@
|
||||||
import 'package:contacts_plus_plus/auxiliary.dart';
|
|
||||||
import 'package:contacts_plus_plus/config.dart';
|
import 'package:contacts_plus_plus/config.dart';
|
||||||
import 'package:contacts_plus_plus/string_formatter.dart';
|
import 'package:contacts_plus_plus/string_formatter.dart';
|
||||||
|
|
||||||
|
|
|
@ -1,23 +1,40 @@
|
||||||
import 'package:cached_network_image/cached_network_image.dart';
|
import 'package:cached_network_image/cached_network_image.dart';
|
||||||
|
import 'package:contacts_plus_plus/apis/session_api.dart';
|
||||||
import 'package:contacts_plus_plus/auxiliary.dart';
|
import 'package:contacts_plus_plus/auxiliary.dart';
|
||||||
|
import 'package:contacts_plus_plus/client_holder.dart';
|
||||||
import 'package:contacts_plus_plus/models/session.dart';
|
import 'package:contacts_plus_plus/models/session.dart';
|
||||||
import 'package:contacts_plus_plus/widgets/formatted_text.dart';
|
import 'package:contacts_plus_plus/widgets/formatted_text.dart';
|
||||||
import 'package:contacts_plus_plus/widgets/settings_page.dart';
|
import 'package:contacts_plus_plus/widgets/settings_page.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:photo_view/photo_view.dart';
|
import 'package:photo_view/photo_view.dart';
|
||||||
|
|
||||||
class SessionView extends StatelessWidget {
|
class SessionView extends StatefulWidget {
|
||||||
const SessionView({required this.session, super.key});
|
const SessionView({required this.session, super.key});
|
||||||
|
|
||||||
final Session session;
|
final Session session;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<SessionView> createState() => _SessionViewState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SessionViewState extends State<SessionView> {
|
||||||
|
|
||||||
|
Future<Session>? _sessionFuture;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_sessionFuture = Future.value(widget.session);
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return FutureBuilder(
|
||||||
body: CustomScrollView(
|
future: _sessionFuture,
|
||||||
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
|
builder: (context, snapshot) {
|
||||||
slivers: [
|
final session = snapshot.data ?? widget.session;
|
||||||
SliverAppBar(
|
return Scaffold(
|
||||||
|
appBar: AppBar(
|
||||||
leading: IconButton(
|
leading: IconButton(
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.arrow_back_outlined,
|
Icons.arrow_back_outlined,
|
||||||
|
@ -26,12 +43,6 @@ class SessionView extends StatelessWidget {
|
||||||
Navigator.of(context).pop();
|
Navigator.of(context).pop();
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
pinned: true,
|
|
||||||
snap: false,
|
|
||||||
floating: false,
|
|
||||||
expandedHeight: 192,
|
|
||||||
surfaceTintColor: Theme.of(context).colorScheme.surfaceVariant,
|
|
||||||
centerTitle: true,
|
|
||||||
title: FormattedText(
|
title: FormattedText(
|
||||||
session.formattedName,
|
session.formattedName,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
|
@ -42,146 +53,152 @@ class SessionView extends StatelessWidget {
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
width: double.infinity,
|
width: double.infinity,
|
||||||
height: 1,
|
height: 1,
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
)),
|
),
|
||||||
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
flexibleSpace: FlexibleSpaceBar(
|
),
|
||||||
collapseMode: CollapseMode.pin,
|
body: RefreshIndicator(
|
||||||
background: Hero(
|
onRefresh: () async {
|
||||||
tag: session.id,
|
setState(() {
|
||||||
child: CachedNetworkImage(
|
_sessionFuture = SessionApi.getSession(ClientHolder.of(context).apiClient, sessionId: session.id);
|
||||||
imageUrl: Aux.neosDbToHttp(session.thumbnail),
|
});
|
||||||
imageBuilder: (context, image) {
|
await _sessionFuture;
|
||||||
return Material(
|
},
|
||||||
child: InkWell(
|
child: ListView(
|
||||||
onTap: () async {
|
children: <Widget>[
|
||||||
await Navigator.push(
|
SizedBox(
|
||||||
context,
|
height: 192,
|
||||||
MaterialPageRoute(
|
child: Hero(
|
||||||
builder: (context) => PhotoView(
|
tag: session.id,
|
||||||
minScale: PhotoViewComputedScale.contained,
|
child: CachedNetworkImage(
|
||||||
imageProvider: image,
|
imageUrl: Aux.neosDbToHttp(session.thumbnail),
|
||||||
heroAttributes: PhotoViewHeroAttributes(tag: session.id),
|
imageBuilder: (context, image) {
|
||||||
),
|
return Material(
|
||||||
|
child: InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
await Navigator.push(
|
||||||
|
context,
|
||||||
|
MaterialPageRoute(
|
||||||
|
builder: (context) => PhotoView(
|
||||||
|
minScale: PhotoViewComputedScale.contained,
|
||||||
|
imageProvider: image,
|
||||||
|
heroAttributes: PhotoViewHeroAttributes(tag: session.id),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
child: Image(
|
||||||
|
image: image,
|
||||||
|
fit: BoxFit.cover,
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
},
|
);
|
||||||
child: Image(
|
},
|
||||||
image: image,
|
errorWidget: (context, url, error) => const Icon(
|
||||||
fit: BoxFit.cover,
|
Icons.broken_image,
|
||||||
|
size: 64,
|
||||||
|
),
|
||||||
|
placeholder: (context, uri) => const Center(child: CircularProgressIndicator()),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(top: 12),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8),
|
||||||
|
child: session.formattedDescription.isEmpty
|
||||||
|
? Text("No description", style: Theme.of(context).textTheme.labelLarge)
|
||||||
|
: FormattedText(
|
||||||
|
session.formattedDescription,
|
||||||
|
style: Theme.of(context).textTheme.titleLarge,
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
const ListSectionHeader(
|
||||||
},
|
leadingText: "Tags:",
|
||||||
errorWidget: (context, url, error) => const Icon(
|
showLine: false,
|
||||||
Icons.broken_image,
|
),
|
||||||
size: 64,
|
Padding(
|
||||||
),
|
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8.0),
|
||||||
placeholder: (context, uri) => const Center(child: CircularProgressIndicator()),
|
child: Text(
|
||||||
),
|
session.tags.isEmpty ? "None" : session.tags.join(", "),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
SliverToBoxAdapter(
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.only(top: 12),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: [
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8),
|
|
||||||
child: session.formattedDescription.isEmpty
|
|
||||||
? Text("No description", style: Theme.of(context).textTheme.labelLarge)
|
|
||||||
: FormattedText(
|
|
||||||
session.formattedDescription,
|
|
||||||
style: Theme.of(context).textTheme.titleLarge,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const ListSectionHeader(
|
|
||||||
leadingText: "Tags:",
|
|
||||||
showLine: false,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8.0),
|
|
||||||
child: Text(
|
|
||||||
session.tags.isEmpty ? "None" : session.tags.join(", "),
|
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
softWrap: true,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const ListSectionHeader(
|
|
||||||
leadingText: "Details:",
|
|
||||||
showLine: false,
|
|
||||||
),
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Access: ",
|
|
||||||
style: Theme.of(context).textTheme.labelLarge,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
session.accessLevel.toReadableString(),
|
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
softWrap: true,
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
const ListSectionHeader(
|
||||||
),
|
leadingText: "Details:",
|
||||||
Padding(
|
showLine: false,
|
||||||
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8),
|
),
|
||||||
child: Row(
|
Padding(
|
||||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
padding: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||||
children: [
|
child: Row(
|
||||||
Text(
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
"Headless: ",
|
children: [
|
||||||
style: Theme.of(context).textTheme.labelLarge,
|
Text(
|
||||||
|
"Access: ",
|
||||||
|
style: Theme.of(context).textTheme.labelLarge,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
session.accessLevel.toReadableString(),
|
||||||
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
session.headlessHost ? "Yes" : "No",
|
Padding(
|
||||||
style: Theme.of(context).textTheme.labelMedium,
|
padding: const EdgeInsets.only(left: 16.0, right: 16.0, bottom: 8),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||||
|
children: [
|
||||||
|
Text(
|
||||||
|
"Headless: ",
|
||||||
|
style: Theme.of(context).textTheme.labelLarge,
|
||||||
|
),
|
||||||
|
Text(
|
||||||
|
session.headlessHost ? "Yes" : "No",
|
||||||
|
style: Theme.of(context).textTheme.labelMedium,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
ListSectionHeader(
|
||||||
),
|
leadingText: "Users",
|
||||||
ListSectionHeader(
|
trailingText:
|
||||||
leadingText: "Users",
|
|
||||||
trailingText:
|
|
||||||
"${session.sessionUsers.length.toString().padLeft(2, "0")}/${session.maxUsers.toString().padLeft(2, "0")}",
|
"${session.sessionUsers.length.toString().padLeft(2, "0")}/${session.maxUsers.toString().padLeft(2, "0")}",
|
||||||
showLine: false,
|
showLine: false,
|
||||||
|
),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
] +
|
||||||
|
session.sessionUsers
|
||||||
|
.map((user) => ListTile(
|
||||||
|
dense: true,
|
||||||
|
title: Text(
|
||||||
|
user.username,
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
),
|
||||||
|
subtitle: Text(
|
||||||
|
user.isPresent ? "Active" : "Inactive",
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
SliverList(
|
);
|
||||||
delegate: SliverChildBuilderDelegate(
|
},
|
||||||
(BuildContext context, int index) {
|
|
||||||
final user = session.sessionUsers[index];
|
|
||||||
return ListTile(
|
|
||||||
dense: true,
|
|
||||||
title: Text(
|
|
||||||
user.username,
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
),
|
|
||||||
subtitle: Text(
|
|
||||||
user.isPresent ? "Active" : "Inactive",
|
|
||||||
textAlign: TextAlign.start,
|
|
||||||
),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
childCount: session.sessionUsers.length,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue