✨ Realm detail
This commit is contained in:
@ -1,7 +1,6 @@
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_animate/flutter_animate.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:infinite_scroll_pagination/infinite_scroll_pagination.dart';
|
||||
import 'package:solian/exts.dart';
|
||||
@ -221,8 +220,6 @@ class _ChannelChatScreenState extends State<ChannelChatScreen> {
|
||||
clipBehavior: Clip.none,
|
||||
pagingController: _pagingController,
|
||||
builderDelegate: PagedChildBuilderDelegate<Message>(
|
||||
animateTransitions: true,
|
||||
transitionDuration: 350.ms,
|
||||
itemBuilder: chatHistoryBuilder,
|
||||
noItemsFoundIndicatorBuilder: (_) => Container(),
|
||||
),
|
||||
|
@ -78,8 +78,6 @@ class _ChannelDetailScreenState extends State<ChannelDetailScreen> {
|
||||
.pushNamed(
|
||||
'channelOrganizing',
|
||||
extra: ChannelOrganizeArguments(edit: widget.channel),
|
||||
queryParameters:
|
||||
widget.realm != 'global' ? {'realm': widget.realm} : {},
|
||||
)
|
||||
.then((resp) {
|
||||
if (resp != null) {
|
||||
|
@ -1,7 +1,13 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
import 'package:solian/models/realm.dart';
|
||||
import 'package:solian/providers/auth.dart';
|
||||
import 'package:solian/router.dart';
|
||||
import 'package:solian/screens/realms/realm_organize.dart';
|
||||
import 'package:solian/widgets/realms/realm_deletion.dart';
|
||||
import 'package:solian/widgets/realms/realm_member.dart';
|
||||
|
||||
class RealmDetailScreen extends StatelessWidget {
|
||||
class RealmDetailScreen extends StatefulWidget {
|
||||
final String alias;
|
||||
final Realm realm;
|
||||
|
||||
@ -11,8 +17,132 @@ class RealmDetailScreen extends StatelessWidget {
|
||||
required this.realm,
|
||||
});
|
||||
|
||||
@override
|
||||
State<RealmDetailScreen> createState() => _RealmDetailScreenState();
|
||||
}
|
||||
|
||||
class _RealmDetailScreenState extends State<RealmDetailScreen> {
|
||||
bool _isOwned = false;
|
||||
|
||||
void checkOwner() async {
|
||||
final AuthProvider auth = Get.find();
|
||||
final prof = await auth.getProfile();
|
||||
setState(() {
|
||||
_isOwned = prof.body['id'] == widget.realm.accountId;
|
||||
});
|
||||
}
|
||||
|
||||
void showMemberList() {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
useRootNavigator: true,
|
||||
isScrollControlled: true,
|
||||
builder: (context) => RealmMemberListPopup(
|
||||
realm: widget.realm,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
void promptLeaveChannel() async {
|
||||
final did = await showDialog(
|
||||
context: context,
|
||||
builder: (context) => RealmDeletion(
|
||||
realm: widget.realm,
|
||||
isOwned: _isOwned,
|
||||
),
|
||||
);
|
||||
if (did == true && AppRouter.instance.canPop()) {
|
||||
AppRouter.instance.pop(false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
|
||||
checkOwner();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
throw UnimplementedError();
|
||||
final ownerActions = [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.edit),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: Text('realmAdjust'.tr),
|
||||
onTap: () async {
|
||||
AppRouter.instance
|
||||
.pushNamed(
|
||||
'realmOrganizing',
|
||||
extra: RealmOrganizeArguments(edit: widget.realm),
|
||||
)
|
||||
.then((resp) {
|
||||
if (resp != null) {
|
||||
AppRouter.instance.pop(resp);
|
||||
}
|
||||
});
|
||||
},
|
||||
),
|
||||
];
|
||||
|
||||
return Column(
|
||||
children: [
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 12),
|
||||
child: Row(
|
||||
children: [
|
||||
const CircleAvatar(
|
||||
radius: 28,
|
||||
backgroundColor: Colors.teal,
|
||||
child: Icon(Icons.group, color: Colors.white),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
Expanded(
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(widget.realm.name,
|
||||
style: Theme.of(context).textTheme.bodyLarge),
|
||||
Text(widget.realm.description,
|
||||
style: Theme.of(context).textTheme.bodySmall),
|
||||
Text(
|
||||
'#${widget.realm.id.toString().padLeft(8, '0')} · ${widget.realm.alias}',
|
||||
style: const TextStyle(fontSize: 11),
|
||||
),
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(thickness: 0.3),
|
||||
Expanded(
|
||||
child: ListView(
|
||||
children: [
|
||||
ListTile(
|
||||
leading: const Icon(Icons.settings),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: Text('realmSettings'.tr),
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.supervisor_account),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
title: Text('realmMembers'.tr),
|
||||
onTap: () => showMemberList(),
|
||||
),
|
||||
...(_isOwned ? ownerActions : List.empty()),
|
||||
const Divider(thickness: 0.3),
|
||||
ListTile(
|
||||
leading: _isOwned
|
||||
? const Icon(Icons.delete)
|
||||
: const Icon(Icons.exit_to_app),
|
||||
title: Text(_isOwned ? 'delete'.tr : 'leave'.tr),
|
||||
onTap: () => promptLeaveChannel(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ class _RealmOrganizeScreenState extends State<RealmOrganizeScreen> {
|
||||
child: Text('cancel'.tr),
|
||||
),
|
||||
],
|
||||
),
|
||||
).paddingOnly(bottom: 6),
|
||||
Row(
|
||||
children: [
|
||||
Expanded(
|
||||
|
Reference in New Issue
Block a user