|
|
|
|
@ -1,15 +1,12 @@
|
|
|
|
|
import 'dart:math';
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:collection/collection.dart';
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
|
|
|
|
import 'package:future_loading_dialog/future_loading_dialog.dart';
|
|
|
|
|
import 'package:matrix/matrix.dart';
|
|
|
|
|
|
|
|
|
|
import 'package:fluffychat/config/app_config.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
|
|
|
|
import 'package:fluffychat/pangea/utils/error_handler.dart';
|
|
|
|
|
import '../../../widgets/matrix.dart';
|
|
|
|
|
import '../../utils/firebase_analytics.dart';
|
|
|
|
|
import 'add_class_and_invite.dart';
|
|
|
|
|
@ -192,23 +189,48 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
if (parents.any((r) => r.room.id == possibleParent.id))
|
|
|
|
|
SwitchListTile.adaptive(
|
|
|
|
|
title: Text(
|
|
|
|
|
AnimatedSize(
|
|
|
|
|
duration: const Duration(milliseconds: 300),
|
|
|
|
|
curve: Curves.easeInOut,
|
|
|
|
|
child: parents.any((r) => r.room.id == possibleParent.id)
|
|
|
|
|
? SwitchListTile.adaptive(
|
|
|
|
|
title: Row(
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(width: 32),
|
|
|
|
|
Text(
|
|
|
|
|
L10n.of(context)!.suggestTo(possibleParentName),
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
subtitle: Text(
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
subtitle: Row(
|
|
|
|
|
children: [
|
|
|
|
|
const SizedBox(width: 32),
|
|
|
|
|
Expanded(
|
|
|
|
|
child: Text(
|
|
|
|
|
widget.mode == AddToClassMode.chat
|
|
|
|
|
? L10n.of(context)!.suggestChatDesc(possibleParentName)
|
|
|
|
|
: L10n.of(context)!.suggestExchangeDesc(possibleParentName),
|
|
|
|
|
? L10n.of(context)!
|
|
|
|
|
.suggestChatDesc(possibleParentName)
|
|
|
|
|
: L10n.of(context)!.suggestExchangeDesc(
|
|
|
|
|
possibleParentName,
|
|
|
|
|
),
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
activeColor: AppConfig.activeToggleColor,
|
|
|
|
|
value: isSuggestedInSpace(possibleParent),
|
|
|
|
|
onChanged: (bool suggest) =>
|
|
|
|
|
setSuggested(suggest, possibleParent),
|
|
|
|
|
)
|
|
|
|
|
: Container(),
|
|
|
|
|
),
|
|
|
|
|
Divider(
|
|
|
|
|
height: 0.5,
|
|
|
|
|
color: Theme.of(context).colorScheme.secondary.withAlpha(25),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
@ -223,7 +245,6 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|
|
|
|
final String subtitle = widget.mode == AddToClassMode.exchange
|
|
|
|
|
? L10n.of(context)!.addToClassDesc
|
|
|
|
|
: L10n.of(context)!.addToClassOrExchangeDesc;
|
|
|
|
|
final scrollController = ScrollController();
|
|
|
|
|
|
|
|
|
|
return Column(
|
|
|
|
|
children: [
|
|
|
|
|
@ -253,27 +274,10 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
|
|
|
|
|
if (isOpen) ...[
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
possibleParents.isNotEmpty
|
|
|
|
|
? Scrollbar(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
thumbVisibility: true,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
controller: scrollController,
|
|
|
|
|
child: Column(
|
|
|
|
|
children: [
|
|
|
|
|
const Divider(height: 1),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: min(possibleParents.length * 55, 500),
|
|
|
|
|
child: ListView.builder(
|
|
|
|
|
shrinkWrap: true,
|
|
|
|
|
itemCount: possibleParents.length,
|
|
|
|
|
itemBuilder: (BuildContext context, int i) {
|
|
|
|
|
return getAddToSpaceToggleItem(i);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
? Column(
|
|
|
|
|
children: possibleParents
|
|
|
|
|
.mapIndexed((index, _) => getAddToSpaceToggleItem(index))
|
|
|
|
|
.toList(),
|
|
|
|
|
)
|
|
|
|
|
: Center(
|
|
|
|
|
child: Padding(
|
|
|
|
|
|