Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #88 from charafau/update-other-software
Browse files Browse the repository at this point in the history
Screen 6 - Updates and other software
  • Loading branch information
oSoMoN committed Jun 1, 2021
2 parents acaf228 + 9882e78 commit 6d12835
Show file tree
Hide file tree
Showing 6 changed files with 226 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/ubuntu_desktop_installer/lib/app.dart
Expand Up @@ -7,6 +7,7 @@ import 'l10n/app_localizations.dart';
import 'pages/keyboard_layout_page.dart';
import 'pages/try_or_install_page.dart';
import 'pages/turn_off_rst_page.dart';
import 'pages/updates_other_software/updates_other_software_page.dart';
import 'pages/welcome_page.dart';
import 'routes.dart';

Expand Down Expand Up @@ -43,6 +44,7 @@ class UbuntuDesktopInstallerApp extends StatelessWidget {
Routes.tryOrInstall: (context) => TryOrInstallPage(),
Routes.turnOffRST: (context) => const TurnOffRSTPage(),
Routes.keyboardLayout: (context) => KeyboardLayoutPage(),
Routes.updatesOtherSoftware: UpdatesOtherSoftwarePage.create,
},
),
);
Expand Down
13 changes: 12 additions & 1 deletion packages/ubuntu_desktop_installer/lib/l10n/app_en.arb
Expand Up @@ -65,5 +65,16 @@
"@typeToTest": {},

"detectLayout": "Detect Keyboard Layout",
"@detectLayout": {}
"@detectLayout": {},

"updatesOtherSoftwarePageTitle": "Updates and other software",
"updatesOtherSoftwarePageDescription": "What apps would you like to install to start with?",

"normalInstallationTitle": "Normal installation",
"normalInstallationSubtitle": "Web browser, utilities, office software, games and media players.",
"minimalInstallationTitle": "Minimal installation",
"minimalInstallationSubtitle": "Web browser and basic utilities.",
"otherOptions": "Other options",
"installThirdPartyTitle": "Install third-party software for graphics and Wi-Fi hardware and additional media formats",
"installThirdPartySubtitle": "This software is subject to license terms included with its documentation. Some is proprietary."
}
@@ -0,0 +1,37 @@
import 'package:flutter/foundation.dart';

enum InstallationMode { normal, minimal }

class UpdateOtherSoftwareModel extends ChangeNotifier {
// ignore: public_member_api_docs
UpdateOtherSoftwareModel(
{required InstallationMode installationMode,
bool installThirdParty = false})
: _mode = installationMode,
_installThirdParty = installThirdParty;

InstallationMode _mode;
InstallationMode get installationMode => _mode;

bool _installThirdParty;
bool get installThirdParty => _installThirdParty;

void setInstallationMode(InstallationMode? mode) {
if (mode == null || _mode == mode) {
return;
}

_mode = mode;
notifyListeners();
}

void setInstallThirdParty(bool? installThirdParty) {
if (installThirdParty == null || _installThirdParty == installThirdParty) {
return;
}

_installThirdParty = installThirdParty;

notifyListeners();
}
}
@@ -0,0 +1,100 @@
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';

import '../../widgets.dart';
import '../../widgets/localized_view.dart';
import 'updates_other_software_model.dart';

const _kButtonPadding = EdgeInsets.only(right: 20, bottom: 20);

class UpdatesOtherSoftwarePage extends StatefulWidget {
@override
_UpdatesOtherSoftwarePageState createState() =>
_UpdatesOtherSoftwarePageState();

static Widget create(BuildContext context) {
return ChangeNotifierProvider(
create: (context) =>
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal),
child: UpdatesOtherSoftwarePage(),
);
}
}

class _UpdatesOtherSoftwarePageState extends State<UpdatesOtherSoftwarePage> {
@override
Widget build(BuildContext context) {
final model = context.watch<UpdateOtherSoftwareModel>();
return LocalizedView(
builder: (context, lang) => Scaffold(
appBar: AppBar(
title: Text(lang.updatesOtherSoftwarePageTitle),
automaticallyImplyLeading: false,
),
body: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Padding(
padding: const EdgeInsets.only(left: 20, top: 20, bottom: 8),
child: Align(
alignment: Alignment.centerLeft,
child: Text(lang.updatesOtherSoftwarePageDescription),
),
),
RadioListTile<InstallationMode>(
title: Text(lang.normalInstallationTitle),
subtitle: Text(lang.normalInstallationSubtitle),
contentPadding: const EdgeInsets.only(left: 20),
value: InstallationMode.normal,
groupValue: model.installationMode,
onChanged: model.setInstallationMode,
),
RadioListTile<InstallationMode>(
title: Text(lang.minimalInstallationTitle),
subtitle: Text(lang.minimalInstallationSubtitle),
value: InstallationMode.minimal,
contentPadding: const EdgeInsets.only(left: 20),
groupValue: model.installationMode,
onChanged: model.setInstallationMode,
),
const SizedBox(height: 24),
Padding(
padding: const EdgeInsets.only(left: 20),
child: Align(
alignment: Alignment.centerLeft,
child: Text(lang.otherOptions),
),
),
CheckboxListTile(
title: Text(lang.installThirdPartyTitle),
subtitle: Text(lang.installThirdPartySubtitle),
controlAffinity: ListTileControlAffinity.leading,
contentPadding: const EdgeInsets.only(left: 20),
value: model.installThirdParty,
onChanged: model.setInstallThirdParty,
)
],
),
),
bottomNavigationBar: Padding(
padding: _kButtonPadding,
child: ButtonBar(
children: <Widget>[
OutlinedButton(
child: Text(lang.backButtonText),
onPressed: Navigator.of(context).pop,
),
OutlinedButton(
child: Text(lang.continueButtonText),
onPressed: () {
// TODO: add next step here
},
),
],
),
),
),
);
}
}
1 change: 1 addition & 0 deletions packages/ubuntu_desktop_installer/lib/routes.dart
Expand Up @@ -4,4 +4,5 @@ abstract class Routes {
static const keyboardLayout = '/keyboardlayout';
static const repairUbuntu = '/repairubuntu';
static const tryUbuntu = '/tryubuntu';
static const updatesOtherSoftware = '/updateothersoftware';
}
@@ -0,0 +1,74 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:ubuntu_desktop_installer/pages/updates_other_software/updates_other_software_model.dart';

void main() {
group('UpdatesOtherSoftwareModel', () {
test('init state should be ablet to set installation mode', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

expect(model.installationMode, InstallationMode.normal);
});

test('should notify listeners when set installation mode', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

InstallationMode? mode;

model.addListener(() => mode = model.installationMode);

model.setInstallationMode(InstallationMode.minimal);

expect(mode, InstallationMode.minimal);
});

test('should have third party option set to false by default', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

expect(model.installThirdParty, false);
});

test('should be able to set third party', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

bool? shouldInstallThirdParty;

model
.addListener(() => shouldInstallThirdParty = model.installThirdParty);

model.setInstallThirdParty(true);

expect(shouldInstallThirdParty, true);
});

test('should not notify installation mode when passed null', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

InstallationMode? mode;

model.addListener(() => mode = model.installationMode);

model.setInstallationMode(null);

expect(mode, null);
});

test('should not notify third party when passed null', () {
final model =
UpdateOtherSoftwareModel(installationMode: InstallationMode.normal);

bool? shouldInstallThirdParty;

model
.addListener(() => shouldInstallThirdParty = model.installThirdParty);

model.setInstallThirdParty(null);

expect(shouldInstallThirdParty, null);
});
});
}

0 comments on commit 6d12835

Please sign in to comment.