Skip to content

Commit

Permalink
Merge pull request #164 from pangeachat/usability
Browse files Browse the repository at this point in the history
Usability
  • Loading branch information
ggurdin authored May 6, 2024
2 parents bcb15c4 + ab9f7e2 commit eb08ccd
Show file tree
Hide file tree
Showing 9 changed files with 67 additions and 80 deletions.
11 changes: 8 additions & 3 deletions assets/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -2123,9 +2123,13 @@
"placeholders": {}
},
"writeAMessage": "Write a message…",
"@writeAMessage": {
"writeAMessageFlag": "Write a message in {l1flag} or {l2flag}…",
"@writeAMessageFlag": {
"type": "text",
"placeholders": {}
"placeholders": {
"l1flag": {},
"l2flag": {}
}
},
"yes": "Yes",
"@yes": {
Expand Down Expand Up @@ -3989,5 +3993,6 @@
"unread": {}
}
},
"messageAnalytics": "Message Analytics"
"messageAnalytics": "Message Analytics",
"noPaymentInfo": "No payment info necessary!"
}
16 changes: 15 additions & 1 deletion lib/pages/chat/chat_input_row.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ class ChatInputRow extends StatelessWidget {
const height = 48.0;

// #Pangea
final activel1 =
controller.pangeaController.languageController.activeL1Model();
final activel2 =
controller.pangeaController.languageController.activeL2Model();

return Column(
children: [
ITBar(
Expand Down Expand Up @@ -325,7 +330,16 @@ class ChatInputRow extends StatelessWidget {
bottom: 6.0,
top: 3.0,
),
hintText: L10n.of(context)!.writeAMessage,
hintText: activel1 != null && activel2 != null
? L10n.of(context)!.writeAMessageFlag(
activel1.languageEmoji ??
activel1.getDisplayName(context) ??
activel1.langCode,
activel2.languageEmoji ??
activel2.getDisplayName(context) ??
activel2.langCode,
)
: L10n.of(context)!.writeAMessage,
hintMaxLines: 1,
border: InputBorder.none,
enabledBorder: InputBorder.none,
Expand Down
29 changes: 14 additions & 15 deletions lib/pages/chat_list/client_chooser_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -297,22 +297,21 @@ class ClientChooserButton extends StatelessWidget {
// onKeysPressed: () => _previousAccount(matrix, context),
// child: const SizedBox.shrink(),
// ),
// Pangea#
PopupMenuButton<Object>(
onSelected: (o) => _clientSelected(o, context),
itemBuilder: _bundleMenuItems,
// #Pangea
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Material(
borderRadius: const BorderRadius.only(
bottomLeft: Radius.circular(12),
bottomRight: Radius.circular(12),
),
clipBehavior: Clip.hardEdge,
child: ListTile(
tileColor: Theme.of(context).scaffoldBackgroundColor,
hoverColor: Theme.of(context).colorScheme.onSurfaceVariant,
leading: const Icon(Icons.settings_outlined),
title: Text(L10n.of(context)!.mainMenu),
color: Colors.transparent,
child:
// Pangea#
PopupMenuButton<Object>(
onSelected: (o) => _clientSelected(o, context),
itemBuilder: _bundleMenuItems,
// #Pangea
child: ListTile(
mouseCursor: SystemMouseCursors.click,
leading: const Icon(Icons.settings_outlined),
title: Text(L10n.of(context)!.mainMenu),
),
),
),
// child: Material(
Expand Down
2 changes: 1 addition & 1 deletion lib/pangea/choreographer/controllers/choreographer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class Choreographer {
OverlayUtil.showPositionedCard(
context: context,
cardToShow: const PaywallCard(),
cardSize: const Size(325, 375),
cardSize: const Size(325, 325),
transformTargetId: inputTransformTargetKey,
);
return;
Expand Down
26 changes: 14 additions & 12 deletions lib/pangea/controllers/language_controller.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import 'dart:developer';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

import 'package:matrix/matrix.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import 'package:fluffychat/pangea/constants/language_keys.dart';
import 'package:fluffychat/pangea/controllers/language_list_controller.dart';
import 'package:fluffychat/pangea/controllers/pangea_controller.dart';
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
import 'package:fluffychat/pangea/models/class_model.dart';
import 'package:fluffychat/pangea/models/language_model.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:matrix/matrix.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

import '../widgets/user_settings/p_language_dialog.dart';

class LanguageController {
Expand All @@ -31,16 +30,19 @@ class LanguageController {
);
return;
}
if (_userL1Code == null ||
_userL2Code == null ||
_userL1Code!.isEmpty ||
_userL2Code!.isEmpty ||
_userL1Code == LanguageKeys.unknownLanguage ||
_userL2Code == LanguageKeys.unknownLanguage) {
if (!languagesSet) {
pLanguageDialog(dialogContext, callback);
}
}

bool get languagesSet =>
_userL1Code != null &&
_userL2Code != null &&
_userL1Code!.isNotEmpty &&
_userL2Code!.isNotEmpty &&
_userL1Code != LanguageKeys.unknownLanguage &&
_userL2Code != LanguageKeys.unknownLanguage;

String? get _userL1Code {
final source =
_pangeaController.userController.userModel?.profile?.sourceLanguage;
Expand Down
5 changes: 5 additions & 0 deletions lib/pangea/models/language_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class LanguageModel {
final String langCode;
final String languageFlag;
final String displayName;
final String? languageEmoji;
final bool l2;
final bool l1;

Expand All @@ -20,6 +21,7 @@ class LanguageModel {
required this.displayName,
required this.l2,
required this.l1,
this.languageEmoji,
});

factory LanguageModel.fromJson(json) {
Expand All @@ -37,6 +39,7 @@ class LanguageModel {
),
l2: json["l2"] ?? code.contains("es") || code.contains("en"),
l1: json["l1"] ?? !code.contains("es") && !code.contains("en"),
languageEmoji: json['language_emoji'],
);
}

Expand All @@ -46,6 +49,7 @@ class LanguageModel {
'language_flag': languageFlag,
'l2': l2,
'l1': l1,
'language_emoji': languageEmoji,
};

// Discuss with Jordan - adding langCode field to language objects as separate from displayName
Expand Down Expand Up @@ -81,6 +85,7 @@ class LanguageModel {
l1: false,
langCode: LanguageKeys.multiLanguage,
languageFlag: 'assets/colors.png',
languageEmoji: "🌎",
);

// Discuss with Jordan
Expand Down
5 changes: 4 additions & 1 deletion lib/pangea/widgets/igc/pangea_rich_text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class PangeaRichText extends StatefulWidget {
class PangeaRichTextState extends State<PangeaRichText> {
final PangeaController pangeaController = MatrixState.pangeaController;
bool _fetchingRepresentation = false;
double get blur => _fetchingRepresentation && widget.immersionMode ? 5 : 0;
double get blur => (_fetchingRepresentation && widget.immersionMode) ||
!pangeaController.languageController.languagesSet
? 5
: 0;
String textSpan = "";
PangeaRepresentation? repEvent;

Expand Down
2 changes: 1 addition & 1 deletion lib/pangea/widgets/igc/pangea_text_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class PangeaTextController extends TextEditingController {
OverlayUtil.showPositionedCard(
context: context,
cardToShow: const PaywallCard(),
cardSize: const Size(325, 375),
cardSize: const Size(325, 325),
transformTargetId: choreographer.inputTransformTargetKey,
);
}
Expand Down
51 changes: 5 additions & 46 deletions lib/pangea/widgets/igc/paywall_card.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:fluffychat/pangea/widgets/igc/card_header.dart';
import 'package:fluffychat/widgets/matrix.dart';
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/l10n.dart';
import 'package:shimmer/shimmer.dart';

class PaywallCard extends StatelessWidget {
const PaywallCard({
Expand All @@ -31,13 +30,16 @@ class PaywallCard extends StatelessWidget {
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
const OptionsShimmer(),
const SizedBox(height: 15.0),
Text(
L10n.of(context)!.subscriptionPopupDesc,
style: BotStyle.text(context),
textAlign: TextAlign.center,
),
Text(
L10n.of(context)!.noPaymentInfo,
style: BotStyle.text(context),
textAlign: TextAlign.center,
),
const SizedBox(height: 15.0),
SizedBox(
width: double.infinity,
Expand Down Expand Up @@ -88,46 +90,3 @@ class PaywallCard extends StatelessWidget {
);
}
}

class OptionsShimmer extends StatelessWidget {
const OptionsShimmer({super.key});

@override
Widget build(BuildContext context) {
return Shimmer.fromColors(
baseColor: Theme.of(context).colorScheme.primary.withOpacity(0.5),
highlightColor: Theme.of(context).colorScheme.primary.withOpacity(0.1),
direction: ShimmerDirection.ltr,
child: Wrap(
alignment: WrapAlignment.center,
children: List.generate(
3,
(_) => Container(
margin: const EdgeInsets.all(2),
padding: EdgeInsets.zero,
child: TextButton(
style: ButtonStyle(
padding: MaterialStateProperty.all(
const EdgeInsets.symmetric(horizontal: 7),
),
backgroundColor: MaterialStateProperty.all<Color>(
Theme.of(context).colorScheme.primary.withOpacity(0.1),
),
shape: MaterialStateProperty.all(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10),
),
),
),
onPressed: () {},
child: Text(
"",
style: BotStyle.text(context),
),
),
),
),
),
);
}
}

0 comments on commit eb08ccd

Please sign in to comment.