Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 32 additions & 5 deletions lib/src/constants/initial_setup.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,14 @@ const initialStructureTitle = 'Solid Pod';

/// Text string variables used for informing the user about the first-time
/// connection and security key requirement.
///
/// The [appName] parameter allows the message to display the actual app name
/// instead of a generic "this App" reference.

const initialStructureMsg =
'You have connected to your Solid Pod using this App for the first time. '
'A security key is required to encrypt and protect the data stored in your Pod. '
'You must remember this security key to access the data for this App.';
String initialStructureMsg(String appName) =>
'You have connected to your Solid Pod using $appName for the first time. '
'A security key is required to encrypt and protect the data stored in your '
'Pod. You must remember this security key to access the data for $appName.';

/// The string key of input form for the input of security key

Expand All @@ -75,9 +78,33 @@ const securityKeyStrReType = '__security_key';
/// Markdown tooltip text for the security key input field.

const securityKeyTooltip =
'A security key can be any string of characters that you can remember.'
'A security key can be any string of characters that you can remember. '
'The longer the better, with a mix of characters.';

const securityKeyRetypeTooltip =
'Please retype your security key to ensure it is correct. '
'We ask this to protect against loss of your data.';

/// Tooltip text for the SUBMIT button.
///
/// The [appName] parameter allows the tooltip to display the actual app name.

String submitButtonTooltip(String appName) =>
'Tap here once you have provided your security key. '
'This will record the key and create the Pod folder for $appName.';

/// Tooltip text for the RESOURCES button.
///
/// The [appName] parameter allows the tooltip to display the actual app name.

String resourcesButtonTooltip(String appName) =>
'Tap here to list all of the $appName resources '
'that will be created to initialise your Pod.';

/// Tooltip text for the LOGOUT button.
///
/// The [appName] parameter allows the tooltip to display the actual app name.

String logoutButtonTooltip(String appName) =>
'Tap here to logout from your connection to your Pod on the Solid server. '
'Next time you start $appName you will need to log into the server again.';
98 changes: 66 additions & 32 deletions lib/src/screens/initial_setup_screen_body.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ library;
import 'package:flutter/material.dart';

import 'package:flutter_form_builder/flutter_form_builder.dart';
import 'package:markdown_tooltip/markdown_tooltip.dart';
import 'package:package_info_plus/package_info_plus.dart';

import 'package:solidui/solidui.dart' show SolidLogin, logoutPopup;
import 'package:solidui/src/constants/initial_setup.dart';
import 'package:solidui/src/screens/initial_setup_widgets/enc_key_input_form.dart';
import 'package:solidui/src/screens/initial_setup_widgets/initial_setup_welcome.dart';
import 'package:solidui/src/screens/initial_setup_widgets/res_create_form_submission.dart';
Expand Down Expand Up @@ -84,6 +87,27 @@ class _InitialSetupScreenBodyState extends State<InitialSetupScreenBody> {

final _formKey = GlobalKey<FormBuilderState>();

String _appName = 'the App';

@override
void initState() {
super.initState();
_loadAppName();
}

Future<void> _loadAppName() async {
final packageInfo = await PackageInfo.fromPlatform();
if (mounted) {
setState(() {
// Capitalise the first letter of the app name for display.
final name = packageInfo.appName;
_appName = name.isNotEmpty
? name[0].toUpperCase() + name.substring(1)
: 'the App';
});
}
}

@override
Widget build(BuildContext context) {
final resFoldersLink = (widget.resNeedToCreate['folders'] as List)
Expand Down Expand Up @@ -156,7 +180,7 @@ class _InitialSetupScreenBodyState extends State<InitialSetupScreenBody> {
child: ListView(
primary: false,
children: [
initialSetupWelcome(context),
initialSetupWelcome(context, _appName),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 30),
child: Column(
Expand Down Expand Up @@ -242,19 +266,22 @@ class _InitialSetupScreenBodyState extends State<InitialSetupScreenBody> {
) {
return FocusTraversalOrder(
order: const NumericFocusOrder(3),
child: OutlinedButton(
onPressed: () async => _handleFormSubmit(
resFileNames,
resFoldersLink,
resFilesLink,
),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.blue,
side: const BorderSide(color: Colors.blue),
),
child: const Text(
'SUBMIT',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
child: MarkdownTooltip(
message: submitButtonTooltip(_appName),
child: OutlinedButton(
onPressed: () async => _handleFormSubmit(
resFileNames,
resFoldersLink,
resFilesLink,
),
style: OutlinedButton.styleFrom(
foregroundColor: Colors.blue,
side: const BorderSide(color: Colors.blue),
),
child: const Text(
'SUBMIT',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 14),
),
),
),
);
Expand All @@ -266,33 +293,40 @@ class _InitialSetupScreenBodyState extends State<InitialSetupScreenBody> {
List<String?> extractedParts,
) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
mainAxisAlignment: MainAxisAlignment.end,
children: [
FocusTraversalOrder(
order: const NumericFocusOrder(4),
child: TextButton(
onPressed: () =>
ResourcesDialog.show(context, baseUrl, extractedParts),
child: const Text(
'RESOURCES',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16,
child: MarkdownTooltip(
message: resourcesButtonTooltip(_appName),
child: TextButton(
onPressed: () =>
ResourcesDialog.show(context, baseUrl, extractedParts),
child: const Text(
'RESOURCES',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
),
const SizedBox(width: 16),
FocusTraversalOrder(
order: const NumericFocusOrder(5),
child: TextButton(
onPressed: () async => await logoutPopup(context, widget.child),
child: const Text(
'LOGOUT',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16,
child: MarkdownTooltip(
message: logoutButtonTooltip(_appName),
child: TextButton(
onPressed: () async => await logoutPopup(context, widget.child),
child: const Text(
'LOGOUT',
style: TextStyle(
color: Colors.grey,
fontWeight: FontWeight.bold,
fontSize: 16,
),
),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ import 'package:solidui/src/widgets/build_message_container.dart';
/// A widget displaying an alert for the user noting that they have probably a
/// newly created Solid Pod or their App's Pod is missing resources.
///
/// The widget will inform the user about creating/ re-creating these recources.
/// The widget will inform the user about creating/ re-creating these resources.
///
/// The [appName] parameter is used to display the actual app name in the
/// message instead of a generic reference.

SizedBox initialSetupWelcome(BuildContext context) {
SizedBox initialSetupWelcome(BuildContext context, String appName) {
return SizedBox(
child: Padding(
padding: const EdgeInsets.all(30.0),
Expand Down Expand Up @@ -87,7 +90,7 @@ SizedBox initialSetupWelcome(BuildContext context) {
context,
'warning',
'', // No title for the message box.
initialStructureMsg,
initialStructureMsg(appName),
),
),
],
Expand Down