chore: move learning settings button to fix overflow in analytics summary (#1929)

This commit is contained in:
ggurdin 2025-02-26 11:06:28 -05:00 committed by GitHub
parent 534fe2dfee
commit 6618fdeb46
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 115 additions and 104 deletions

View file

@ -3,6 +3,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:matrix/matrix.dart';
import 'package:fluffychat/pages/chat_list/client_chooser_button.dart';
import 'package:fluffychat/pangea/analytics_details_popup/analytics_details_popup.dart';
@ -38,6 +39,7 @@ class LearningProgressIndicatorsState
StreamSubscription<AnalyticsStreamUpdate>? _analyticsSubscription;
StreamSubscription? _languageSubscription;
Profile? _profile;
@override
void initState() {
@ -57,6 +59,12 @@ class LearningProgressIndicatorsState
MatrixState.pangeaController.userController.stateStream.listen((_) {
if (mounted) setState(() {});
});
final client = MatrixState.pangeaController.matrixState.client;
if (client.userID == null) return;
client.getProfileFromUserId(client.userID!).then((profile) {
if (mounted) setState(() => _profile = profile);
});
}
@override
@ -92,6 +100,9 @@ class LearningProgressIndicatorsState
final userL2 = MatrixState.pangeaController.languageController.userL2;
final mxid = Matrix.of(context).client.userID ?? L10n.of(context).user;
final displayname = _profile?.displayName ?? mxid.localpart ?? mxid;
return Row(
children: [
const ClientChooserButton(),
@ -100,17 +111,18 @@ class LearningProgressIndicatorsState
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
Matrix.of(context).client.userID ?? L10n.of(context).user,
style: TextStyle(
color: Theme.of(context).colorScheme.primary,
fontSize: 12,
),
),
const SizedBox(height: 6),
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
spacing: 6.0,
children: [
Text(
displayname,
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
LearningSettingsButton(
onTap: () => showDialog(
context: context,
@ -118,28 +130,30 @@ class LearningProgressIndicatorsState
),
l2: userL2?.langCode.toUpperCase(),
),
Row(
children: ConstructTypeEnum.values
.map(
(c) => ProgressIndicatorBadge(
points: uniqueLemmas(c.indicator),
loading: _loading,
onTap: () {
showDialog<AnalyticsPopupWrapper>(
context: context,
builder: (context) => AnalyticsPopupWrapper(
view: c,
),
);
},
indicator: c.indicator,
),
)
.toList(),
),
],
),
const SizedBox(height: 6),
Row(
spacing: 6.0,
children: ConstructTypeEnum.values
.map(
(c) => ProgressIndicatorBadge(
points: uniqueLemmas(c.indicator),
loading: _loading,
onTap: () {
showDialog<AnalyticsPopupWrapper>(
context: context,
builder: (context) => AnalyticsPopupWrapper(
view: c,
),
);
},
indicator: c.indicator,
),
)
.toList(),
),
const SizedBox(height: 6),
MouseRegion(
cursor: SystemMouseCursors.click,
child: GestureDetector(

View file

@ -17,41 +17,41 @@ class LearningSettingsButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Tooltip(
message: L10n.of(context).learningSettings,
child: PressableButton(
buttonHeight: 2.5,
borderRadius: BorderRadius.circular(15),
onPressed: onTap,
color: Theme.of(context).colorScheme.surfaceBright,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Theme.of(context).colorScheme.surfaceBright,
return Row(
mainAxisSize: MainAxisSize.min,
spacing: 4.0,
children: [
Text(
l2 ?? "?",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
),
Tooltip(
message: L10n.of(context).learningSettings,
child: PressableButton(
buttonHeight: 2.5,
borderRadius: BorderRadius.circular(15),
onPressed: onTap,
color: Theme.of(context).colorScheme.surfaceBright,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Theme.of(context).colorScheme.surfaceBright,
),
padding: const EdgeInsets.all(4.0),
child: Icon(
size: 14,
Icons.language,
Icons.settings_outlined,
color: Theme.of(context).colorScheme.primary,
weight: 1000,
),
const SizedBox(width: 5),
Text(
l2 ?? "?",
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: Theme.of(context).colorScheme.primary,
),
),
],
),
),
),
),
],
);
}
}

View file

@ -20,58 +20,55 @@ class ProgressIndicatorBadge extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(left: 6),
child: Tooltip(
message: indicator.tooltip(context),
child: PressableButton(
color: Theme.of(context).colorScheme.surfaceBright,
borderRadius: BorderRadius.circular(15),
onPressed: onTap,
buttonHeight: 2.5,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Theme.of(context).colorScheme.surfaceBright,
),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
size: 14,
indicator.icon,
return Tooltip(
message: indicator.tooltip(context),
child: PressableButton(
color: Theme.of(context).colorScheme.surfaceBright,
borderRadius: BorderRadius.circular(15),
onPressed: onTap,
buttonHeight: 2.5,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(15),
color: Theme.of(context).colorScheme.surfaceBright,
),
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Icon(
size: 14,
indicator.icon,
color: indicator.color(context),
weight: 1000,
),
const SizedBox(width: 4.0),
Text(
indicator.tooltip(context),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: indicator.color(context),
weight: 1000,
),
const SizedBox(width: 4.0),
Text(
indicator.tooltip(context),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: indicator.color(context),
),
),
const SizedBox(width: 4.0),
!loading
? Text(
points.toString(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: indicator.color(context),
),
)
: const SizedBox(
height: 8,
width: 8,
child: CircularProgressIndicator.adaptive(
strokeWidth: 2,
),
),
const SizedBox(width: 4.0),
!loading
? Text(
points.toString(),
style: TextStyle(
fontSize: 12,
fontWeight: FontWeight.bold,
color: indicator.color(context),
),
],
),
)
: const SizedBox(
height: 8,
width: 8,
child: CircularProgressIndicator.adaptive(
strokeWidth: 2,
),
),
],
),
),
),