This repository has been archived by the owner on Mar 6, 2024. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from charafau/update-other-software
Screen 6 - Updates and other software
- Loading branch information
Showing
6 changed files
with
226 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
...untu_desktop_installer/lib/pages/updates_other_software/updates_other_software_model.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
...buntu_desktop_installer/lib/pages/updates_other_software/updates_other_software_page.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
}, | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/ubuntu_desktop_installer/test/updates_other_software_model_test.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}); | ||
}); | ||
} |