2
0
mirror of https://gitlab.com/famedly/fluffychat.git synced 2024-12-29 17:52:35 +01:00
fluffychat/lib/pages/settings_stories/settings_stories_view.dart

69 lines
2.4 KiB
Dart
Raw Normal View History

2021-12-25 10:20:18 +01:00
import 'package:flutter/material.dart';
2021-12-28 19:30:19 +01:00
import 'package:flutter_gen/gen_l10n/l10n.dart';
2021-12-25 10:20:18 +01:00
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(
2021-12-28 19:30:19 +01:00
appBar: AppBar(
title: Text(L10n.of(context)!.whoCanSeeMyStories),
2022-01-15 13:18:25 +01:00
elevation: 0,
),
body: Column(
children: [
ListTile(
2021-12-28 19:30:19 +01:00
title: Text(L10n.of(context)!.whoCanSeeMyStoriesDesc),
leading: CircleAvatar(
backgroundColor: Theme.of(context).secondaryHeaderColor,
foregroundColor: Theme.of(context).colorScheme.secondary,
child: const Icon(Icons.lock),
),
),
2022-01-15 13:18:25 +01:00
const Divider(height: 1),
Expanded(
child: 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,
),
);
2022-01-15 13:18:25 +01:00
}
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()),
);
},
);
},
),
),
],
2021-12-25 10:20:18 +01:00
),
);
}
}