mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-09 21:49:31 +01:00
65 lines
2.1 KiB
Dart
65 lines
2.1 KiB
Dart
//@dart=2.12
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
import 'package:fluffychat/pages/settings_stories/settings_stories.dart';
|
|
import 'package:fluffychat/utils/localized_exception_extension.dart';
|
|
import 'package:fluffychat/widgets/avatar.dart';
|
|
|
|
class SettingsStoriesView extends StatelessWidget {
|
|
final SettingsStoriesController controller;
|
|
const SettingsStoriesView(this.controller, {Key? key}) : super(key: key);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text(L10n.of(context)!.whoCanSeeMyStories),
|
|
bottom: PreferredSize(
|
|
preferredSize: const Size.fromHeight(56),
|
|
child: ListTile(
|
|
title: Text(L10n.of(context)!.whoCanSeeMyStoriesDesc),
|
|
leading: CircleAvatar(
|
|
backgroundColor: Theme.of(context).secondaryHeaderColor,
|
|
foregroundColor: Theme.of(context).colorScheme.secondary,
|
|
child: const Icon(Icons.lock),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
body: FutureBuilder(
|
|
future: controller.loadUsers,
|
|
builder: (context, snapshot) {
|
|
final error = snapshot.error;
|
|
if (error != null) {
|
|
return Center(child: Text(error.toLocalizedString(context)));
|
|
}
|
|
if (snapshot.connectionState != ConnectionState.done) {
|
|
return const Center(
|
|
child: CircularProgressIndicator.adaptive(
|
|
strokeWidth: 2,
|
|
));
|
|
}
|
|
return ListView.builder(
|
|
itemCount: controller.users.length,
|
|
itemBuilder: (context, i) {
|
|
final user = controller.users.keys.toList()[i];
|
|
return SwitchListTile.adaptive(
|
|
value: controller.users[user] ?? false,
|
|
onChanged: (_) => controller.toggleUser(user),
|
|
secondary: Avatar(
|
|
mxContent: user.avatarUrl,
|
|
name: user.calcDisplayname(),
|
|
),
|
|
title: Text(user.calcDisplayname()),
|
|
);
|
|
},
|
|
);
|
|
},
|
|
),
|
|
);
|
|
}
|
|
}
|