Playtest updates (#4054)
* update emoji mode icon and tooltip * upload CMS url instead of uploading image bytes to matrix * re-init subscription controller after setting account creation date
This commit is contained in:
parent
54918d4969
commit
d29d69892d
9 changed files with 56 additions and 89 deletions
|
|
@ -201,8 +201,7 @@ class NewGroupController extends State<NewGroup> {
|
|||
announcementsChatName: L10n.of(context).announcements,
|
||||
visibility: sdk.Visibility.private,
|
||||
joinRules: sdk.JoinRules.knock,
|
||||
avatar: avatar,
|
||||
avatarUrl: avatarUrl,
|
||||
avatarUrl: avatarUrl.toString(),
|
||||
);
|
||||
|
||||
if (!mounted) return;
|
||||
|
|
|
|||
|
|
@ -1,10 +1,6 @@
|
|||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:http/http.dart';
|
||||
import 'package:matrix/matrix.dart' as sdk;
|
||||
|
||||
import 'package:fluffychat/l10n/l10n.dart';
|
||||
|
|
@ -27,25 +23,6 @@ class SelectedCourse extends StatefulWidget {
|
|||
class SelectedCourseController extends State<SelectedCourse> {
|
||||
Future<void> launchCourse(CoursePlanModel course) async {
|
||||
final client = Matrix.of(context).client;
|
||||
Uint8List? avatar;
|
||||
Uri? avatarUrl;
|
||||
final imageUrl = course.imageUrl;
|
||||
if (imageUrl != null) {
|
||||
try {
|
||||
final Response response = await http.get(
|
||||
Uri.parse(imageUrl),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
);
|
||||
avatar = response.bodyBytes;
|
||||
avatarUrl = await client.uploadContent(avatar);
|
||||
} catch (e) {
|
||||
debugPrint("Error fetching course image: $e");
|
||||
}
|
||||
}
|
||||
|
||||
final roomId = await client.createPangeaSpace(
|
||||
name: course.title,
|
||||
topic: course.description,
|
||||
|
|
@ -61,8 +38,7 @@ class SelectedCourseController extends State<SelectedCourse> {
|
|||
},
|
||||
),
|
||||
],
|
||||
avatar: avatar,
|
||||
avatarUrl: avatarUrl,
|
||||
avatarUrl: course.imageUrl,
|
||||
spaceChild: 0,
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,3 @@
|
|||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:matrix/matrix.dart' as sdk;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
||||
|
|
@ -18,7 +15,6 @@ import 'package:fluffychat/pangea/course_plans/course_user_event.dart';
|
|||
import 'package:fluffychat/pangea/events/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/pangea/extensions/join_rule_extension.dart';
|
||||
import 'package:fluffychat/pangea/extensions/pangea_room_extension.dart';
|
||||
import 'package:fluffychat/widgets/matrix.dart';
|
||||
|
||||
extension CoursePlanRoomExtension on Room {
|
||||
CoursePlanEvent? get coursePlan {
|
||||
|
|
@ -182,25 +178,6 @@ extension CoursePlanRoomExtension on Room {
|
|||
ActivityPlanModel activity,
|
||||
ActivityRole? role,
|
||||
) async {
|
||||
Uri? avatarUrl;
|
||||
if (activity.imageURL != null) {
|
||||
try {
|
||||
final http.Response response = await http.get(
|
||||
Uri.parse(activity.imageURL!),
|
||||
headers: {
|
||||
'Authorization':
|
||||
'Bearer ${MatrixState.pangeaController.userController.accessToken}',
|
||||
},
|
||||
);
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Failed to load course image');
|
||||
}
|
||||
final avatar = response.bodyBytes;
|
||||
avatarUrl = await client.uploadContent(avatar);
|
||||
} catch (e) {
|
||||
debugPrint("Error fetching course image: $e");
|
||||
}
|
||||
}
|
||||
final roomID = await client.createRoom(
|
||||
creationContent: {
|
||||
'type': "${PangeaRoomTypes.activitySession}:${activity.activityId}",
|
||||
|
|
@ -213,10 +190,10 @@ extension CoursePlanRoomExtension on Room {
|
|||
type: PangeaEventTypes.activityPlan,
|
||||
content: activity.toJson(),
|
||||
),
|
||||
if (avatarUrl != null)
|
||||
if (activity.imageURL != null)
|
||||
StateEvent(
|
||||
type: EventTypes.RoomAvatar,
|
||||
content: {'url': avatarUrl.toString()},
|
||||
content: {'url': activity.imageURL!},
|
||||
),
|
||||
if (role != null)
|
||||
StateEvent(
|
||||
|
|
|
|||
|
|
@ -241,6 +241,8 @@ class UserSettingsState extends State<UserSettingsPage> {
|
|||
},
|
||||
),
|
||||
);
|
||||
|
||||
await _pangeaController.subscriptionController.reinitialize();
|
||||
context.go(
|
||||
_pangeaController.classController.cachedClassCode == null
|
||||
? '/user_age/join_space'
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import 'dart:math';
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:matrix/matrix.dart';
|
||||
|
|
@ -18,8 +17,7 @@ extension SpacesClientExtension on Client {
|
|||
String? topic,
|
||||
Visibility visibility = Visibility.private,
|
||||
JoinRules joinRules = JoinRules.public,
|
||||
Uint8List? avatar,
|
||||
Uri? avatarUrl,
|
||||
String? avatarUrl,
|
||||
List<StateEvent>? initialState,
|
||||
int spaceChild = 50,
|
||||
}) async {
|
||||
|
|
@ -37,10 +35,10 @@ extension SpacesClientExtension on Client {
|
|||
await pangeaJoinRules(
|
||||
joinRules.toString().replaceAll('JoinRules.', ''),
|
||||
),
|
||||
if (avatar != null)
|
||||
if (avatarUrl != null)
|
||||
StateEvent(
|
||||
type: EventTypes.RoomAvatar,
|
||||
content: {'url': avatarUrl.toString()},
|
||||
content: {'url': avatarUrl},
|
||||
),
|
||||
if (initialState != null) ...initialState,
|
||||
],
|
||||
|
|
|
|||
|
|
@ -65,6 +65,13 @@ class SubscriptionController extends BaseController {
|
|||
Completer<void> initCompleter = Completer<void>();
|
||||
|
||||
Future<void> initialize() async {
|
||||
if (_userID == null || !_pangeaController.matrixState.client.isLogged()) {
|
||||
debugPrint(
|
||||
"Attempted to initalize subscription information with null userId",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (initCompleter.isCompleted) return;
|
||||
if (_isInitializing) {
|
||||
await initCompleter.future;
|
||||
|
|
@ -84,13 +91,6 @@ class SubscriptionController extends BaseController {
|
|||
|
||||
Future<void> _initialize() async {
|
||||
try {
|
||||
if (_userID == null) {
|
||||
debugPrint(
|
||||
"Attempted to initalize subscription information with null userId",
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
await _pangeaController.userController.initCompleter.future;
|
||||
|
||||
availableSubscriptionInfo = AvailableSubscriptionsInfo();
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ extension MessageModeExtension on MessageMode {
|
|||
case MessageMode.messageMeaning:
|
||||
return Icons.star;
|
||||
case MessageMode.wordEmoji:
|
||||
return Icons.add_reaction_outlined;
|
||||
return Symbols.imagesmode;
|
||||
case MessageMode.wordMorph:
|
||||
return Symbols.toys_and_games;
|
||||
}
|
||||
|
|
@ -72,13 +72,12 @@ extension MessageModeExtension on MessageMode {
|
|||
return '';
|
||||
case MessageMode.messageMeaning:
|
||||
return L10n.of(context).meaning;
|
||||
//TODO: add L10n
|
||||
case MessageMode.wordEmoji:
|
||||
return "Emoji";
|
||||
return L10n.of(context).image;
|
||||
case MessageMode.wordMorph:
|
||||
return "Grammar";
|
||||
return L10n.of(context).grammar;
|
||||
case MessageMode.wordMeaning:
|
||||
return "Meaning";
|
||||
return L10n.of(context).meaning;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,11 +99,11 @@ extension MessageModeExtension on MessageMode {
|
|||
return L10n.of(context).meaning;
|
||||
//TODO: add L10n
|
||||
case MessageMode.wordEmoji:
|
||||
return "Emoji";
|
||||
return L10n.of(context).image;
|
||||
case MessageMode.wordMorph:
|
||||
return "Grammar";
|
||||
return L10n.of(context).grammar;
|
||||
case MessageMode.wordMeaning:
|
||||
return "Meaning";
|
||||
return L10n.of(context).meaning;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ enum SelectMode {
|
|||
audio(Icons.volume_up),
|
||||
translate(Icons.translate),
|
||||
practice(Symbols.fitness_center),
|
||||
emoji(Icons.add_reaction_outlined),
|
||||
emoji(Symbols.imagesmode),
|
||||
speechTranslation(Icons.translate);
|
||||
|
||||
final IconData icon;
|
||||
|
|
@ -45,7 +45,7 @@ enum SelectMode {
|
|||
case SelectMode.practice:
|
||||
return l10n.practice;
|
||||
case SelectMode.emoji:
|
||||
return l10n.emojis;
|
||||
return l10n.image;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import 'package:matrix/matrix.dart';
|
|||
|
||||
import 'package:fluffychat/pangea/bot/utils/bot_name.dart';
|
||||
import 'package:fluffychat/pangea/bot/widgets/bot_face_svg.dart';
|
||||
import 'package:fluffychat/pangea/common/widgets/url_image_widget.dart';
|
||||
import 'package:fluffychat/utils/string_color.dart';
|
||||
import 'package:fluffychat/widgets/mxc_image.dart';
|
||||
import 'package:fluffychat/widgets/presence_builder.dart';
|
||||
|
|
@ -102,22 +103,37 @@ class Avatar extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
)
|
||||
: MxcImage(
|
||||
client: client,
|
||||
key: ValueKey(mxContent.toString()),
|
||||
cacheKey: '${mxContent}_$size',
|
||||
uri: mxContent,
|
||||
fit: BoxFit.cover,
|
||||
width: size,
|
||||
height: size,
|
||||
placeholder: (_) => Center(
|
||||
child: Icon(
|
||||
Icons.person_2,
|
||||
color: theme.colorScheme.tertiary,
|
||||
size: size / 1.5,
|
||||
// #Pangea
|
||||
: !(mxContent.toString().startsWith('mxc://'))
|
||||
? ImageByUrl(
|
||||
imageUrl: mxContent.toString(),
|
||||
width: size,
|
||||
replacement: Center(
|
||||
child: Icon(
|
||||
icon ?? Icons.person_2,
|
||||
color: theme.colorScheme.tertiary,
|
||||
size: size / 1.5,
|
||||
),
|
||||
),
|
||||
borderRadius: borderRadius,
|
||||
)
|
||||
// Pangea#
|
||||
: MxcImage(
|
||||
client: client,
|
||||
key: ValueKey(mxContent.toString()),
|
||||
cacheKey: '${mxContent}_$size',
|
||||
uri: mxContent,
|
||||
fit: BoxFit.cover,
|
||||
width: size,
|
||||
height: size,
|
||||
placeholder: (_) => Center(
|
||||
child: Icon(
|
||||
Icons.person_2,
|
||||
color: theme.colorScheme.tertiary,
|
||||
size: size / 1.5,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
// #Pangea
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue