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/string_formatter.dart';
|
||||
|
||||
|
|
|
@ -1,23 +1,40 @@
|
|||
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/client_holder.dart';
|
||||
import 'package:contacts_plus_plus/models/session.dart';
|
||||
import 'package:contacts_plus_plus/widgets/formatted_text.dart';
|
||||
import 'package:contacts_plus_plus/widgets/settings_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
class SessionView extends StatelessWidget {
|
||||
class SessionView extends StatefulWidget {
|
||||
const SessionView({required this.session, super.key});
|
||||
|
||||
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
|
||||
Widget build(BuildContext context) {
|
||||
return FutureBuilder(
|
||||
future: _sessionFuture,
|
||||
builder: (context, snapshot) {
|
||||
final session = snapshot.data ?? widget.session;
|
||||
return Scaffold(
|
||||
body: CustomScrollView(
|
||||
physics: const BouncingScrollPhysics(decelerationRate: ScrollDecelerationRate.fast),
|
||||
slivers: [
|
||||
SliverAppBar(
|
||||
appBar: AppBar(
|
||||
leading: IconButton(
|
||||
icon: const Icon(
|
||||
Icons.arrow_back_outlined,
|
||||
|
@ -26,12 +43,6 @@ class SessionView extends StatelessWidget {
|
|||
Navigator.of(context).pop();
|
||||
},
|
||||
),
|
||||
pinned: true,
|
||||
snap: false,
|
||||
floating: false,
|
||||
expandedHeight: 192,
|
||||
surfaceTintColor: Theme.of(context).colorScheme.surfaceVariant,
|
||||
centerTitle: true,
|
||||
title: FormattedText(
|
||||
session.formattedName,
|
||||
maxLines: 1,
|
||||
|
@ -46,13 +57,24 @@ class SessionView extends StatelessWidget {
|
|||
width: double.infinity,
|
||||
height: 1,
|
||||
color: Colors.black,
|
||||
)),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
flexibleSpace: FlexibleSpaceBar(
|
||||
collapseMode: CollapseMode.pin,
|
||||
background: Hero(
|
||||
),
|
||||
body: RefreshIndicator(
|
||||
onRefresh: () async {
|
||||
setState(() {
|
||||
_sessionFuture = SessionApi.getSession(ClientHolder.of(context).apiClient, sessionId: session.id);
|
||||
});
|
||||
await _sessionFuture;
|
||||
},
|
||||
child: ListView(
|
||||
children: <Widget>[
|
||||
SizedBox(
|
||||
height: 192,
|
||||
child: Hero(
|
||||
tag: session.id,
|
||||
child: CachedNetworkImage(
|
||||
imageUrl: Aux.neosDbToHttp(session.thumbnail),
|
||||
|
@ -86,9 +108,7 @@ class SessionView extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverToBoxAdapter(
|
||||
child: Padding(
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(top: 12),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
|
@ -160,12 +180,9 @@ class SessionView extends StatelessWidget {
|
|||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
SliverList(
|
||||
delegate: SliverChildBuilderDelegate(
|
||||
(BuildContext context, int index) {
|
||||
final user = session.sessionUsers[index];
|
||||
return ListTile(
|
||||
] +
|
||||
session.sessionUsers
|
||||
.map((user) => ListTile(
|
||||
dense: true,
|
||||
title: Text(
|
||||
user.username,
|
||||
|
@ -175,13 +192,13 @@ class SessionView extends StatelessWidget {
|
|||
user.isPresent ? "Active" : "Inactive",
|
||||
textAlign: TextAlign.start,
|
||||
),
|
||||
))
|
||||
.toList(),
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
childCount: session.sessionUsers.length,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue