updates to UI of add to space toggles, makes all class options visible without scrolling

pull/795/head
ggurdin 2 years ago
parent 0dbd87dba1
commit 61e1259a24

@ -1,15 +1,12 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:collection/collection.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:flutter_gen/gen_l10n/l10n.dart';
import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart';
import 'package:matrix/matrix.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 '../../../widgets/matrix.dart';
import '../../utils/firebase_analytics.dart'; import '../../utils/firebase_analytics.dart';
import 'add_class_and_invite.dart'; import 'add_class_and_invite.dart';
@ -192,24 +189,49 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
), ),
), ),
), ),
if (parents.any((r) => r.room.id == possibleParent.id)) AnimatedSize(
SwitchListTile.adaptive( duration: const Duration(milliseconds: 300),
title: Text( curve: Curves.easeInOut,
L10n.of(context)!.suggestTo(possibleParentName), child: parents.any((r) => r.room.id == possibleParent.id)
style: TextStyle( ? SwitchListTile.adaptive(
color: Theme.of(context).colorScheme.secondary, title: Row(
), children: [
), const SizedBox(width: 32),
subtitle: Text( Text(
widget.mode == AddToClassMode.chat L10n.of(context)!.suggestTo(possibleParentName),
? L10n.of(context)!.suggestChatDesc(possibleParentName) style: TextStyle(
: L10n.of(context)!.suggestExchangeDesc(possibleParentName), color: Theme.of(context).colorScheme.secondary,
), ),
activeColor: AppConfig.activeToggleColor, ),
value: isSuggestedInSpace(possibleParent), ],
onChanged: (bool suggest) => ),
setSuggested(suggest, possibleParent), subtitle: Row(
), children: [
const SizedBox(width: 32),
Expanded(
child: Text(
widget.mode == AddToClassMode.chat
? 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 final String subtitle = widget.mode == AddToClassMode.exchange
? L10n.of(context)!.addToClassDesc ? L10n.of(context)!.addToClassDesc
: L10n.of(context)!.addToClassOrExchangeDesc; : L10n.of(context)!.addToClassOrExchangeDesc;
final scrollController = ScrollController();
return Column( return Column(
children: [ children: [
@ -253,27 +274,10 @@ class AddToSpaceState extends State<AddToSpaceToggles> {
if (isOpen) ...[ if (isOpen) ...[
const Divider(height: 1), const Divider(height: 1),
possibleParents.isNotEmpty possibleParents.isNotEmpty
? Scrollbar( ? Column(
controller: scrollController, children: possibleParents
thumbVisibility: true, .mapIndexed((index, _) => getAddToSpaceToggleItem(index))
child: SingleChildScrollView( .toList(),
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);
},
),
),
],
),
),
) )
: Center( : Center(
child: Padding( child: Padding(

Loading…
Cancel
Save