diff --git a/lib/pages/settings/settings_view.dart b/lib/pages/settings/settings_view.dart index b830b29c4..3cbd371e4 100644 --- a/lib/pages/settings/settings_view.dart +++ b/lib/pages/settings/settings_view.dart @@ -68,331 +68,336 @@ class SettingsView extends StatelessWidget { // Pangea# body: ListTileTheme( iconColor: theme.colorScheme.onSurface, - child: ListView( - key: const Key('SettingsListViewContent'), - children: [ - FutureBuilder( - future: controller.profileFuture, - builder: (context, snapshot) { - final profile = snapshot.data; - final avatar = profile?.avatarUrl; - final mxid = Matrix.of(context).client.userID ?? - L10n.of(context).user; - final displayname = - profile?.displayName ?? mxid.localpart ?? mxid; - return Row( - children: [ - Padding( - // #Pangea - // padding: const EdgeInsets.all(32.0), - padding: const EdgeInsets.only( - top: 32.0, - bottom: 32.0, - left: 12.0, - ), - // Pangea# - child: Stack( - children: [ - Avatar( - mxContent: avatar, - name: displayname, - // #Pangea - userId: profile?.userId, - // Pangea# - size: Avatar.defaultSize * 2.5, - onTap: avatar != null - ? () => showDialog( - context: context, - builder: (_) => - MxcImageViewer(avatar), - ) - : null, - ), - if (profile != null) - Positioned( - bottom: 0, - right: 0, - child: FloatingActionButton.small( - elevation: 2, - onPressed: controller.setAvatarAction, - heroTag: null, - child: const Icon( - Icons.camera_alt_outlined, + // #Pangea + child: SafeArea( + // Pangea# + child: ListView( + key: const Key('SettingsListViewContent'), + children: [ + FutureBuilder( + future: controller.profileFuture, + builder: (context, snapshot) { + final profile = snapshot.data; + final avatar = profile?.avatarUrl; + final mxid = Matrix.of(context).client.userID ?? + L10n.of(context).user; + final displayname = + profile?.displayName ?? mxid.localpart ?? mxid; + return Row( + children: [ + Padding( + // #Pangea + // padding: const EdgeInsets.all(32.0), + padding: const EdgeInsets.only( + top: 32.0, + bottom: 32.0, + left: 12.0, + ), + // Pangea# + child: Stack( + children: [ + Avatar( + mxContent: avatar, + name: displayname, + // #Pangea + userId: profile?.userId, + // Pangea# + size: Avatar.defaultSize * 2.5, + onTap: avatar != null + ? () => showDialog( + context: context, + builder: (_) => + MxcImageViewer(avatar), + ) + : null, + ), + if (profile != null) + Positioned( + bottom: 0, + right: 0, + child: FloatingActionButton.small( + elevation: 2, + onPressed: controller.setAvatarAction, + heroTag: null, + child: const Icon( + Icons.camera_alt_outlined, + ), ), ), - ), - ], + ], + ), ), - ), - Expanded( - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - TextButton.icon( - onPressed: controller.setDisplaynameAction, - icon: const Icon( - Icons.edit_outlined, - size: 16, - ), - style: TextButton.styleFrom( - foregroundColor: - theme.colorScheme.onSurface, - iconColor: theme.colorScheme.onSurface, - ), - label: Text( - displayname, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: const TextStyle( - fontSize: 18, + Expanded( + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextButton.icon( + onPressed: controller.setDisplaynameAction, + icon: const Icon( + Icons.edit_outlined, + size: 16, + ), + style: TextButton.styleFrom( + foregroundColor: + theme.colorScheme.onSurface, + iconColor: theme.colorScheme.onSurface, + ), + label: Text( + displayname, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: const TextStyle( + fontSize: 18, + ), ), ), - ), - TextButton.icon( - onPressed: () => - FluffyShare.share(mxid, context), - icon: const Icon( - Icons.copy_outlined, - size: 14, - ), - style: TextButton.styleFrom( - foregroundColor: - theme.colorScheme.secondary, - iconColor: theme.colorScheme.secondary, - ), - label: Text( - mxid, - maxLines: 1, - overflow: TextOverflow.ellipsis, - // style: const TextStyle(fontSize: 12), - ), - ), - // #Pangea - TextButton.icon( - onPressed: controller.setStatus, - icon: const Icon( - Icons.add, - size: 14, - ), - style: TextButton.styleFrom( - foregroundColor: - theme.colorScheme.secondary, - iconColor: theme.colorScheme.secondary, + TextButton.icon( + onPressed: () => + FluffyShare.share(mxid, context), + icon: const Icon( + Icons.copy_outlined, + size: 14, + ), + style: TextButton.styleFrom( + foregroundColor: + theme.colorScheme.secondary, + iconColor: theme.colorScheme.secondary, + ), + label: Text( + mxid, + maxLines: 1, + overflow: TextOverflow.ellipsis, + // style: const TextStyle(fontSize: 12), + ), ), - label: Text( - L10n.of(context).setStatus, - maxLines: 1, - overflow: TextOverflow.ellipsis, + // #Pangea + TextButton.icon( + onPressed: controller.setStatus, + icon: const Icon( + Icons.add, + size: 14, + ), + style: TextButton.styleFrom( + foregroundColor: + theme.colorScheme.secondary, + iconColor: theme.colorScheme.secondary, + ), + label: Text( + L10n.of(context).setStatus, + maxLines: 1, + overflow: TextOverflow.ellipsis, + ), ), - ), - // Pangea# - ], - ), - ), - ], - ); - }, - ), - // #Pangea - // if (accountManageUrl != null) - // ListTile( - // leading: const Icon(Icons.account_circle_outlined), - // title: Text(L10n.of(context).manageAccount), - // trailing: const Icon(Icons.open_in_new_outlined), - // onTap: () => launchUrlString( - // accountManageUrl, - // mode: LaunchMode.inAppBrowserView, - // ), - // ), - // Divider(color: theme.dividerColor), - // if (showChatBackupBanner == null) - // ListTile( - // leading: const Icon(Icons.backup_outlined), - // title: Text(L10n.of(context).chatBackup), - // trailing: const CircularProgressIndicator.adaptive(), - // ) - // else - // SwitchListTile.adaptive( - // controlAffinity: ListTileControlAffinity.trailing, - // value: controller.showChatBackupBanner == false, - // secondary: const Icon(Icons.backup_outlined), - // title: Text(L10n.of(context).chatBackup), - // onChanged: controller.firstRunBootstrapAction, - // ), - // Divider( - // color: theme.dividerColor, - // ), - ListTile( - leading: const Icon(Icons.language_outlined), - title: Text(L10n.of(context).learningSettings), - tileColor: - activeRoute.startsWith('/rooms/settings/learning') - ? theme.colorScheme.surfaceContainerHigh - : null, - onTap: () => context.go('/rooms/settings/learning'), - ), - // Pangea# - ListTile( - leading: const Icon(Icons.format_paint_outlined), - title: Text(L10n.of(context).changeTheme), - tileColor: activeRoute.startsWith('/rooms/settings/style') - ? theme.colorScheme.surfaceContainerHigh - : null, - onTap: () => context.go('/rooms/settings/style'), - ), - ListTile( - leading: const Icon(Icons.notifications_outlined), - title: Text(L10n.of(context).notifications), - tileColor: - activeRoute.startsWith('/rooms/settings/notifications') - ? theme.colorScheme.surfaceContainerHigh - : null, - onTap: () => context.go('/rooms/settings/notifications'), - ), - ListTile( - leading: const Icon(Icons.devices_outlined), - title: Text(L10n.of(context).devices), - onTap: () => context.go('/rooms/settings/devices'), - tileColor: activeRoute.startsWith('/rooms/settings/devices') - ? theme.colorScheme.surfaceContainerHigh - : null, - ), - ListTile( - leading: const Icon(Icons.forum_outlined), - title: Text(L10n.of(context).chat), - onTap: () => context.go('/rooms/settings/chat'), - tileColor: activeRoute.startsWith('/rooms/settings/chat') - ? theme.colorScheme.surfaceContainerHigh - : null, - ), - // #Pangea - ListTile( - leading: const Icon(Icons.account_circle_outlined), - title: Text(L10n.of(context).subscriptionManagement), - onTap: () => context.go('/rooms/settings/subscription'), - tileColor: - activeRoute.startsWith('/rooms/settings/subscription') - ? theme.colorScheme.surfaceContainerHigh - : null, - ), - // Pangea# - ListTile( - leading: const Icon(Icons.shield_outlined), - title: Text(L10n.of(context).security), - onTap: () => context.go('/rooms/settings/security'), - tileColor: - activeRoute.startsWith('/rooms/settings/security') - ? theme.colorScheme.surfaceContainerHigh - : null, - ), - Divider(color: theme.dividerColor), - // #Pangea - ListTile( - leading: const Icon(Icons.help_outline_outlined), - title: Text(L10n.of(context).help), - onTap: () async { - await showFutureLoadingDialog( - context: context, - future: () async { - final roomId = - await Matrix.of(context).client.startDirectChat( - Environment.supportUserId, - enableEncryption: false, - ); - context.go('/rooms/$roomId'); - }, - ); - }, - ), - ListTile( - leading: const Icon(Icons.shield_outlined), - title: Text(L10n.of(context).termsAndConditions), - onTap: () => launchUrlString(AppConfig.termsOfServiceUrl), - trailing: const Icon(Icons.open_in_new_outlined), - ), - FutureBuilder( - future: PackageInfo.fromPlatform(), - builder: (context, snapshot) { - if (snapshot.connectionState == ConnectionState.done) { - return ListTile( - leading: const Icon(Icons.info_outline), - trailing: const Icon(Icons.copy_outlined), - onTap: () async { - if (snapshot.data == null) return; - await Clipboard.setData( - ClipboardData( - text: - "${snapshot.data!.version}+${snapshot.data!.buildNumber}", - ), - ); - ScaffoldMessenger.of(context).showSnackBar( - SnackBar( - content: - Text(L10n.of(context).copiedToClipboard), + // Pangea# + ], ), - ); - }, - title: Text( - snapshot.data != null - ? L10n.of(context).versionText( - snapshot.data!.version, - snapshot.data!.buildNumber, - ) - : L10n.of(context).versionNotFound, - ), - ); - } else if (snapshot.hasError) { - return ListTile( - leading: const Icon(Icons.error_outline), - title: Text(L10n.of(context).versionFetchError), + ), + ], ); - } else { - return ListTile( - leading: const CircularProgressIndicator(), - title: Text(L10n.of(context).fetchingVersion), + }, + ), + // #Pangea + // if (accountManageUrl != null) + // ListTile( + // leading: const Icon(Icons.account_circle_outlined), + // title: Text(L10n.of(context).manageAccount), + // trailing: const Icon(Icons.open_in_new_outlined), + // onTap: () => launchUrlString( + // accountManageUrl, + // mode: LaunchMode.inAppBrowserView, + // ), + // ), + // Divider(color: theme.dividerColor), + // if (showChatBackupBanner == null) + // ListTile( + // leading: const Icon(Icons.backup_outlined), + // title: Text(L10n.of(context).chatBackup), + // trailing: const CircularProgressIndicator.adaptive(), + // ) + // else + // SwitchListTile.adaptive( + // controlAffinity: ListTileControlAffinity.trailing, + // value: controller.showChatBackupBanner == false, + // secondary: const Icon(Icons.backup_outlined), + // title: Text(L10n.of(context).chatBackup), + // onChanged: controller.firstRunBootstrapAction, + // ), + // Divider( + // color: theme.dividerColor, + // ), + ListTile( + leading: const Icon(Icons.language_outlined), + title: Text(L10n.of(context).learningSettings), + tileColor: + activeRoute.startsWith('/rooms/settings/learning') + ? theme.colorScheme.surfaceContainerHigh + : null, + onTap: () => context.go('/rooms/settings/learning'), + ), + // Pangea# + ListTile( + leading: const Icon(Icons.format_paint_outlined), + title: Text(L10n.of(context).changeTheme), + tileColor: activeRoute.startsWith('/rooms/settings/style') + ? theme.colorScheme.surfaceContainerHigh + : null, + onTap: () => context.go('/rooms/settings/style'), + ), + ListTile( + leading: const Icon(Icons.notifications_outlined), + title: Text(L10n.of(context).notifications), + tileColor: activeRoute + .startsWith('/rooms/settings/notifications') + ? theme.colorScheme.surfaceContainerHigh + : null, + onTap: () => context.go('/rooms/settings/notifications'), + ), + ListTile( + leading: const Icon(Icons.devices_outlined), + title: Text(L10n.of(context).devices), + onTap: () => context.go('/rooms/settings/devices'), + tileColor: + activeRoute.startsWith('/rooms/settings/devices') + ? theme.colorScheme.surfaceContainerHigh + : null, + ), + ListTile( + leading: const Icon(Icons.forum_outlined), + title: Text(L10n.of(context).chat), + onTap: () => context.go('/rooms/settings/chat'), + tileColor: activeRoute.startsWith('/rooms/settings/chat') + ? theme.colorScheme.surfaceContainerHigh + : null, + ), + // #Pangea + ListTile( + leading: const Icon(Icons.account_circle_outlined), + title: Text(L10n.of(context).subscriptionManagement), + onTap: () => context.go('/rooms/settings/subscription'), + tileColor: + activeRoute.startsWith('/rooms/settings/subscription') + ? theme.colorScheme.surfaceContainerHigh + : null, + ), + // Pangea# + ListTile( + leading: const Icon(Icons.shield_outlined), + title: Text(L10n.of(context).security), + onTap: () => context.go('/rooms/settings/security'), + tileColor: + activeRoute.startsWith('/rooms/settings/security') + ? theme.colorScheme.surfaceContainerHigh + : null, + ), + Divider(color: theme.dividerColor), + // #Pangea + ListTile( + leading: const Icon(Icons.help_outline_outlined), + title: Text(L10n.of(context).help), + onTap: () async { + await showFutureLoadingDialog( + context: context, + future: () async { + final roomId = + await Matrix.of(context).client.startDirectChat( + Environment.supportUserId, + enableEncryption: false, + ); + context.go('/rooms/$roomId'); + }, ); - } - }, - ), - // Conditional ListTile based on the environment (staging or not) - if (Environment.isStagingEnvironment) + }, + ), + ListTile( + leading: const Icon(Icons.shield_outlined), + title: Text(L10n.of(context).termsAndConditions), + onTap: () => launchUrlString(AppConfig.termsOfServiceUrl), + trailing: const Icon(Icons.open_in_new_outlined), + ), + FutureBuilder( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + if (snapshot.connectionState == ConnectionState.done) { + return ListTile( + leading: const Icon(Icons.info_outline), + trailing: const Icon(Icons.copy_outlined), + onTap: () async { + if (snapshot.data == null) return; + await Clipboard.setData( + ClipboardData( + text: + "${snapshot.data!.version}+${snapshot.data!.buildNumber}", + ), + ); + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: + Text(L10n.of(context).copiedToClipboard), + ), + ); + }, + title: Text( + snapshot.data != null + ? L10n.of(context).versionText( + snapshot.data!.version, + snapshot.data!.buildNumber, + ) + : L10n.of(context).versionNotFound, + ), + ); + } else if (snapshot.hasError) { + return ListTile( + leading: const Icon(Icons.error_outline), + title: Text(L10n.of(context).versionFetchError), + ); + } else { + return ListTile( + leading: const CircularProgressIndicator(), + title: Text(L10n.of(context).fetchingVersion), + ); + } + }, + ), + // Conditional ListTile based on the environment (staging or not) + if (Environment.isStagingEnvironment) + ListTile( + leading: const Icon(Icons.bug_report_outlined), + title: Text(L10n.of(context).connectedToStaging), + ), + // ListTile( + // leading: const Icon(Icons.dns_outlined), + // title: Text( + // L10n.of(context).aboutHomeserver( + // Matrix.of(context).client.userID?.domain ?? + // 'homeserver', + // ), + // ), + // onTap: () => context.go('/rooms/settings/homeserver'), + // tileColor: + // activeRoute.startsWith('/rooms/settings/homeserver') + // ? theme.colorScheme.surfaceContainerHigh + // : null, + // ), + // ListTile( + // leading: const Icon(Icons.privacy_tip_outlined), + // title: Text(L10n.of(context).privacy), + // onTap: () => launchUrlString(AppConfig.privacyUrl), + // ), + // ListTile( + // leading: const Icon(Icons.info_outline_rounded), + // title: Text(L10n.of(context).about), + // onTap: () => PlatformInfos.showDialog(context), + // ), + // Pangea# + Divider(color: theme.dividerColor), ListTile( - leading: const Icon(Icons.bug_report_outlined), - title: Text(L10n.of(context).connectedToStaging), + leading: const Icon(Icons.logout_outlined), + title: Text(L10n.of(context).logout), + onTap: controller.logoutAction, ), - // ListTile( - // leading: const Icon(Icons.dns_outlined), - // title: Text( - // L10n.of(context).aboutHomeserver( - // Matrix.of(context).client.userID?.domain ?? - // 'homeserver', - // ), - // ), - // onTap: () => context.go('/rooms/settings/homeserver'), - // tileColor: - // activeRoute.startsWith('/rooms/settings/homeserver') - // ? theme.colorScheme.surfaceContainerHigh - // : null, - // ), - // ListTile( - // leading: const Icon(Icons.privacy_tip_outlined), - // title: Text(L10n.of(context).privacy), - // onTap: () => launchUrlString(AppConfig.privacyUrl), - // ), - // ListTile( - // leading: const Icon(Icons.info_outline_rounded), - // title: Text(L10n.of(context).about), - // onTap: () => PlatformInfos.showDialog(context), - // ), - // Pangea# - Divider(color: theme.dividerColor), - ListTile( - leading: const Icon(Icons.logout_outlined), - title: Text(L10n.of(context).logout), - onTap: controller.logoutAction, - ), - ], + ], + ), ), ), ), diff --git a/lib/pangea/activity_generator/activity_generator_view.dart b/lib/pangea/activity_generator/activity_generator_view.dart index 6a7800f36..fd0fb6110 100644 --- a/lib/pangea/activity_generator/activity_generator_view.dart +++ b/lib/pangea/activity_generator/activity_generator_view.dart @@ -31,262 +31,275 @@ class ActivityGeneratorView extends StatelessWidget { final l10n = L10n.of(context); if (controller.loading) { - return Scaffold( - appBar: AppBar( - title: Text(L10n.of(context).makeYourOwnActivity), - ), - body: const Padding( - padding: EdgeInsets.all(32.0), - child: Center(child: CircularProgressIndicator()), + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text(L10n.of(context).makeYourOwnActivity), + ), + body: const Padding( + padding: EdgeInsets.all(32.0), + child: Center(child: CircularProgressIndicator()), + ), ), ); } else if (controller.error != null || controller.room == null) { - return Scaffold( - appBar: AppBar( - title: Text(L10n.of(context).makeYourOwnActivity), - ), - body: Center( - child: Column( - spacing: 16.0, - mainAxisAlignment: MainAxisAlignment.center, - children: [ - ErrorIndicator( - message: l10n.errorGenerateActivityMessage, - ), - ElevatedButton( - onPressed: controller.generate, - child: Text(l10n.tryAgain), - ), - ], + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text(L10n.of(context).makeYourOwnActivity), + ), + body: Center( + child: Column( + spacing: 16.0, + mainAxisAlignment: MainAxisAlignment.center, + children: [ + ErrorIndicator( + message: l10n.errorGenerateActivityMessage, + ), + ElevatedButton( + onPressed: controller.generate, + child: Text(l10n.tryAgain), + ), + ], + ), ), ), ); } else if (controller.activities != null && controller.activities!.isNotEmpty) { - return ActivityPlannerBuilder( - initialActivity: controller.activities!.first, - initialFilename: controller.filename, - room: controller.room!, - builder: (c) { - return Scaffold( - appBar: AppBar( - title: Text(L10n.of(context).makeYourOwnActivity), - leading: BackButton( - onPressed: () { - c.isLaunching - ? c.setLaunchState(ActivityLaunchState.base) - : controller.clearActivities(); + return SafeArea( + child: ActivityPlannerBuilder( + initialActivity: controller.activities!.first, + initialFilename: controller.filename, + room: controller.room!, + builder: (c) { + return Scaffold( + appBar: AppBar( + title: Text(L10n.of(context).makeYourOwnActivity), + leading: BackButton( + onPressed: () { + c.isLaunching + ? c.setLaunchState(ActivityLaunchState.base) + : controller.clearActivities(); + }, + ), + ), + body: ListView.builder( + padding: const EdgeInsets.all(16), + itemCount: controller.activities!.length, + itemBuilder: (context, index) { + return ActivityPlanCard( + regenerate: () => controller.generate(force: true), + controller: c, + ); }, ), - ), - body: ListView.builder( - padding: const EdgeInsets.all(16), - itemCount: controller.activities!.length, - itemBuilder: (context, index) { - return ActivityPlanCard( - regenerate: () => controller.generate(force: true), - controller: c, - ); - }, - ), - ); - }, + ); + }, + ), ); } - return Scaffold( - appBar: AppBar( - title: Text(L10n.of(context).makeYourOwnActivity), - leading: BackButton( - onPressed: () { - if (controller.activities != null && - controller.activities!.isNotEmpty) { - controller.clearActivities(); - } else { - Navigator.of(context).pop(); - } - }, + return SafeArea( + child: Scaffold( + appBar: AppBar( + title: Text(L10n.of(context).makeYourOwnActivity), + leading: BackButton( + onPressed: () { + if (controller.activities != null && + controller.activities!.isNotEmpty) { + controller.clearActivities(); + } else { + Navigator.of(context).pop(); + } + }, + ), ), - ), - body: Center( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 600), - child: Form( - key: controller.formKey, - child: ListView( - padding: const EdgeInsets.all(16), - children: [ - const InstructionsInlineTooltip( - instructionsEnum: InstructionsEnum.activityPlannerOverview, - ), - Container( - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(12.0), + body: Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 600), + child: Form( + key: controller.formKey, + child: ListView( + padding: const EdgeInsets.all(16), + children: [ + const InstructionsInlineTooltip( + instructionsEnum: InstructionsEnum.activityPlannerOverview, ), - clipBehavior: Clip.hardEdge, - alignment: Alignment.center, - child: ClipRRect( - child: CachedNetworkImage( - fit: BoxFit.cover, - imageUrl: - "${AppConfig.assetsBaseURL}/${ActivitySuggestionsConstants.makeActivityAssetPath}", - placeholder: (context, url) { - return const Center( - child: CircularProgressIndicator(), - ); - }, - errorWidget: (context, url, error) => const SizedBox(), + Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(12.0), + ), + clipBehavior: Clip.hardEdge, + alignment: Alignment.center, + child: ClipRRect( + child: CachedNetworkImage( + fit: BoxFit.cover, + imageUrl: + "${AppConfig.assetsBaseURL}/${ActivitySuggestionsConstants.makeActivityAssetPath}", + placeholder: (context, url) { + return const Center( + child: CircularProgressIndicator(), + ); + }, + errorWidget: (context, url, error) => const SizedBox(), + ), ), ), - ), - const SizedBox(height: 16.0), - PLanguageDropdown( - languages: - MatrixState.pangeaController.pLanguageStore.baseOptions, - onChange: (val) => controller - .setSelectedLanguageOfInstructions(val.langCode), - initialLanguage: controller.selectedLanguageOfInstructions != - null - ? PLanguageStore.byLangCode( - controller.selectedLanguageOfInstructions!, - ) - : MatrixState.pangeaController.languageController.userL1, - isL2List: false, - decorationText: L10n.of(context).languageOfInstructionsLabel, - ), - const SizedBox(height: 16.0), - PLanguageDropdown( - languages: - MatrixState.pangeaController.pLanguageStore.targetOptions, - onChange: (val) => - controller.setSelectedTargetLanguage(val.langCode), - initialLanguage: controller.selectedTargetLanguage != null - ? PLanguageStore.byLangCode( - controller.selectedTargetLanguage!, - ) - : MatrixState.pangeaController.languageController.userL2, - decorationText: L10n.of(context).targetLanguageLabel, - isL2List: true, - ), - const SizedBox(height: 16.0), - SuggestionFormField( - suggestions: controller.topicItems, - validator: controller.validateNotNull, - maxLength: 50, - label: l10n.topicLabel, - placeholder: l10n.topicPlaceholder, - controller: controller.topicController, - ), - const SizedBox(height: 16.0), - SuggestionFormField( - suggestions: controller.objectiveItems, - validator: controller.validateNotNull, - maxLength: 140, - label: l10n.learningObjectiveLabel, - placeholder: l10n.learningObjectivePlaceholder, - controller: controller.objectiveController, - ), - const SizedBox(height: 16.0), - SuggestionFormField( - suggestions: controller.modeItems, - validator: controller.validateNotNull, - maxLength: 50, - label: l10n.modeLabel, - placeholder: l10n.modePlaceholder, - controller: controller.modeController, - ), - const SizedBox(height: 16.0), - TextFormField( - decoration: InputDecoration( - labelText: l10n.numberOfLearners, + const SizedBox(height: 16.0), + PLanguageDropdown( + languages: + MatrixState.pangeaController.pLanguageStore.baseOptions, + onChange: (val) => controller + .setSelectedLanguageOfInstructions(val.langCode), + initialLanguage: + controller.selectedLanguageOfInstructions != null + ? PLanguageStore.byLangCode( + controller.selectedLanguageOfInstructions!, + ) + : MatrixState + .pangeaController.languageController.userL1, + isL2List: false, + decorationText: + L10n.of(context).languageOfInstructionsLabel, ), - textInputAction: TextInputAction.done, - validator: (value) { - if (value == null || value.isEmpty) { - return l10n.mustBeInteger; - } - final n = int.tryParse(value); - if (n == null || n <= 0) { - return l10n.mustBeInteger; - } - if (n > 50) { - return l10n.maxFifty; - } - return null; - }, - onChanged: (val) => controller - .setSelectedNumberOfParticipants(int.tryParse(val)), - initialValue: - controller.selectedNumberOfParticipants?.toString(), - onTapOutside: (_) => - FocusManager.instance.primaryFocus?.unfocus(), - onFieldSubmitted: (_) { - if (controller.formKey.currentState?.validate() ?? false) { - controller.generate(); - } - }, - ), - const SizedBox(height: 16.0), - LanguageLevelDropdown( - onChanged: controller.setSelectedCefrLevel, - initialLevel: controller.selectedCefrLevel, - ), - const SizedBox(height: 16.0), - Row( - children: [ - Expanded( - child: Padding( - padding: const EdgeInsets.only(right: 8.0), - child: ElevatedButton( - onPressed: controller.clearSelections, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon(Symbols.reset_focus), - const SizedBox(width: 8), - Text(L10n.of(context).clear), - ], + const SizedBox(height: 16.0), + PLanguageDropdown( + languages: MatrixState + .pangeaController.pLanguageStore.targetOptions, + onChange: (val) => + controller.setSelectedTargetLanguage(val.langCode), + initialLanguage: controller.selectedTargetLanguage != null + ? PLanguageStore.byLangCode( + controller.selectedTargetLanguage!, + ) + : MatrixState + .pangeaController.languageController.userL2, + decorationText: L10n.of(context).targetLanguageLabel, + isL2List: true, + ), + const SizedBox(height: 16.0), + SuggestionFormField( + suggestions: controller.topicItems, + validator: controller.validateNotNull, + maxLength: 50, + label: l10n.topicLabel, + placeholder: l10n.topicPlaceholder, + controller: controller.topicController, + ), + const SizedBox(height: 16.0), + SuggestionFormField( + suggestions: controller.objectiveItems, + validator: controller.validateNotNull, + maxLength: 140, + label: l10n.learningObjectiveLabel, + placeholder: l10n.learningObjectivePlaceholder, + controller: controller.objectiveController, + ), + const SizedBox(height: 16.0), + SuggestionFormField( + suggestions: controller.modeItems, + validator: controller.validateNotNull, + maxLength: 50, + label: l10n.modeLabel, + placeholder: l10n.modePlaceholder, + controller: controller.modeController, + ), + const SizedBox(height: 16.0), + TextFormField( + decoration: InputDecoration( + labelText: l10n.numberOfLearners, + ), + textInputAction: TextInputAction.done, + validator: (value) { + if (value == null || value.isEmpty) { + return l10n.mustBeInteger; + } + final n = int.tryParse(value); + if (n == null || n <= 0) { + return l10n.mustBeInteger; + } + if (n > 50) { + return l10n.maxFifty; + } + return null; + }, + onChanged: (val) => controller + .setSelectedNumberOfParticipants(int.tryParse(val)), + initialValue: + controller.selectedNumberOfParticipants?.toString(), + onTapOutside: (_) => + FocusManager.instance.primaryFocus?.unfocus(), + onFieldSubmitted: (_) { + if (controller.formKey.currentState?.validate() ?? + false) { + controller.generate(); + } + }, + ), + const SizedBox(height: 16.0), + LanguageLevelDropdown( + onChanged: controller.setSelectedCefrLevel, + initialLevel: controller.selectedCefrLevel, + ), + const SizedBox(height: 16.0), + Row( + children: [ + Expanded( + child: Padding( + padding: const EdgeInsets.only(right: 8.0), + child: ElevatedButton( + onPressed: controller.clearSelections, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Symbols.reset_focus), + const SizedBox(width: 8), + Text(L10n.of(context).clear), + ], + ), ), ), ), - ), - Expanded( - child: Padding( - padding: const EdgeInsets.only(left: 8.0), - child: ElevatedButton( - onPressed: controller.randomizeEnabled - ? controller.randomizeSelections - : null, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon(Icons.shuffle), - const SizedBox(width: 8), - Text(L10n.of(context).randomize), - ], + Expanded( + child: Padding( + padding: const EdgeInsets.only(left: 8.0), + child: ElevatedButton( + onPressed: controller.randomizeEnabled + ? controller.randomizeSelections + : null, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Icons.shuffle), + const SizedBox(width: 8), + Text(L10n.of(context).randomize), + ], + ), ), ), ), - ), - ], - ), - const SizedBox(height: 24.0), - ElevatedButton( - onPressed: () { - if (controller.formKey.currentState?.validate() ?? false) { - controller.generate(); - } - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Icon(Icons.lightbulb_outline), - const SizedBox(width: 8), - Text(l10n.generateActivitiesButton), ], ), - ), - ], + const SizedBox(height: 24.0), + ElevatedButton( + onPressed: () { + if (controller.formKey.currentState?.validate() ?? + false) { + controller.generate(); + } + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Icon(Icons.lightbulb_outline), + const SizedBox(width: 8), + Text(l10n.generateActivitiesButton), + ], + ), + ), + ], + ), ), ), ), diff --git a/lib/pangea/activity_planner/activity_planner_page.dart b/lib/pangea/activity_planner/activity_planner_page.dart index ebca32ae1..e534a0ec9 100644 --- a/lib/pangea/activity_planner/activity_planner_page.dart +++ b/lib/pangea/activity_planner/activity_planner_page.dart @@ -60,94 +60,96 @@ class ActivityPlannerPageState extends State { break; } - return Scaffold( - appBar: ActivityPlannerPageAppBar( - pageMode: pageMode, - roomID: widget.roomID, - ), - body: Center( - child: ConstrainedBox( - constraints: const BoxConstraints(maxWidth: 800.0), - child: Column( - children: [ - if ([PageMode.featuredActivities, PageMode.savedActivities] - .contains(pageMode)) - Padding( - padding: const EdgeInsets.all(16.0), - child: Wrap( - spacing: 12.0, - runSpacing: 12.0, - alignment: WrapAlignment.center, - children: [ - FilterChip( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(32), - ), - label: Row( - spacing: 8.0, - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Symbols.star_shine, size: 24.0), - Text(L10n.of(context).featuredActivities), - ], - ), - selected: pageMode == PageMode.featuredActivities, - onSelected: (_) => _setPageMode( - PageMode.featuredActivities, - ), - ), - FilterChip( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(32), - ), - label: Row( - spacing: 8.0, - mainAxisSize: MainAxisSize.min, - children: [ - const Icon(Icons.save_outlined, size: 24.0), - Text(L10n.of(context).saved), - ], - ), - selected: pageMode == PageMode.savedActivities, - onSelected: (_) => _setPageMode( - PageMode.savedActivities, - ), - ), - FilterChip( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(32), + return SafeArea( + child: Scaffold( + appBar: ActivityPlannerPageAppBar( + pageMode: pageMode, + roomID: widget.roomID, + ), + body: Center( + child: ConstrainedBox( + constraints: const BoxConstraints(maxWidth: 800.0), + child: Column( + children: [ + if ([PageMode.featuredActivities, PageMode.savedActivities] + .contains(pageMode)) + Padding( + padding: const EdgeInsets.all(16.0), + child: Wrap( + spacing: 12.0, + runSpacing: 12.0, + alignment: WrapAlignment.center, + children: [ + FilterChip( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(32), + ), + label: Row( + spacing: 8.0, + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Symbols.star_shine, size: 24.0), + Text(L10n.of(context).featuredActivities), + ], + ), + selected: pageMode == PageMode.featuredActivities, + onSelected: (_) => _setPageMode( + PageMode.featuredActivities, + ), ), - label: Row( - spacing: 8.0, - mainAxisSize: MainAxisSize.min, - children: [ - CustomizedSvg( - svgUrl: - "${AppConfig.assetsBaseURL}/${ActivitySuggestionsConstants.crayonIconPath}", - colorReplacements: { - "#CDBEF9": colorToHex( - theme.colorScheme.secondary, - ), - }, - height: 24.0, - width: 24.0, - ), - Text(L10n.of(context).createActivityPlan), - ], + FilterChip( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(32), + ), + label: Row( + spacing: 8.0, + mainAxisSize: MainAxisSize.min, + children: [ + const Icon(Icons.save_outlined, size: 24.0), + Text(L10n.of(context).saved), + ], + ), + selected: pageMode == PageMode.savedActivities, + onSelected: (_) => _setPageMode( + PageMode.savedActivities, + ), ), - selected: false, - onSelected: (_) => context.go( - '/rooms/spaces/${widget.roomID}/details/planner/generator', + FilterChip( + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(32), + ), + label: Row( + spacing: 8.0, + mainAxisSize: MainAxisSize.min, + children: [ + CustomizedSvg( + svgUrl: + "${AppConfig.assetsBaseURL}/${ActivitySuggestionsConstants.crayonIconPath}", + colorReplacements: { + "#CDBEF9": colorToHex( + theme.colorScheme.secondary, + ), + }, + height: 24.0, + width: 24.0, + ), + Text(L10n.of(context).createActivityPlan), + ], + ), + selected: false, + onSelected: (_) => context.go( + '/rooms/spaces/${widget.roomID}/details/planner/generator', + ), ), - ), - ], + ], + ), ), - ), - body ?? - ErrorIndicator( - message: L10n.of(context).oopsSomethingWentWrong, - ), - ], + body ?? + ErrorIndicator( + message: L10n.of(context).oopsSomethingWentWrong, + ), + ], + ), ), ), ),