Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Jun 3, 2021
1 parent 727a2a1 commit b9d0c5d
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 40 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## Unreleased

### Fixed

- master channel not showing in installed releases

## 0.0.7 - 2021-06-02

### Changed
Expand Down
2 changes: 1 addition & 1 deletion analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
include: package:effective_dart/analysis_options.yaml
include: package:pedantic/analysis_options.yaml
analyzer:
exclude:
# Ignore generated files
Expand Down
2 changes: 1 addition & 1 deletion lib/src/modules/common/app_shell.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class AppShell extends HookWidget {
// Render corret page widget based on index
Widget renderPage(int index) {
const pages = [
HomeScreen(),
FVMScreen(),
ProjectsScreen(),
ReleasesScreen(),
PackagesScreen(),
Expand Down
2 changes: 1 addition & 1 deletion lib/src/modules/common/utils/helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '../constants.dart';
extension StringExtension on String {
///Capitalizes a string
String capitalize() {
return "${this[0].toUpperCase()}${substring(1)}";
return '${this[0].toUpperCase()}${substring(1)}';
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/src/modules/fvm/fvm.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ final unusedVersionProvider = Provider((ref) {
final releases = ref.watch(releasesStateProvider);

final projects = ref.watch(projectsPerVersionProvider);
for (var version in releases.allCached) {
for (var version in releases.all) {
// If its not in project and its not global
if (projects[version.name] == null && version.isGlobal == false) {
unusedVersions.add(version);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/modules/fvm/fvm.screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import 'components/fvm_cache_size.dart';
import 'components/fvm_empty_releases.dart';
import 'components/fvm_release_list_item.dart';

class HomeScreen extends HookWidget {
const HomeScreen({Key key}) : super(key: key);
class FVMScreen extends HookWidget {
const FVMScreen({Key key}) : super(key: key);

@override
Widget build(BuildContext context) {
final cachedVersions = useProvider(releasesStateProvider).allCached;
final cachedVersions = useProvider(releasesStateProvider).all;

if (cachedVersions == null) {
return const Center(child: CircularProgressIndicator());
Expand All @@ -35,10 +35,10 @@ class HomeScreen extends HookWidget {
Tooltip(
message: 'Clean up unused versions.',
child: OutlinedButton(
child: const Text('Clean up'),
onPressed: () async {
await cleanupUnusedDialog(context);
},
child: const Text('Clean up'),
),
)
],
Expand Down
2 changes: 1 addition & 1 deletion lib/src/modules/projects/components/project_list_item.dart
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ProjectListItem extends HookWidget {

@override
Widget build(BuildContext context) {
final cachedVersions = useProvider(releasesStateProvider).allCached;
final cachedVersions = useProvider(releasesStateProvider).all;

final version = useProvider(getVersionProvider(project.pinnedVersion));

Expand Down
28 changes: 10 additions & 18 deletions lib/src/modules/releases/releases.provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,30 @@ class AppReleasesState {
MasterDto master;
List<ChannelDto> channels;
List<VersionDto> versions;
Map<String, ReleaseDto> allMap;

bool hasGlobal;
AppReleasesState({
this.channels,
this.versions,
this.master,
this.allMap,
this.hasGlobal = false,
}) {
channels = <ChannelDto>[];
versions = <VersionDto>[];
allMap = {};
}

/// Returns all releases and channels
List<ReleaseDto> get all {
Map<String, ReleaseDto> get allMap {
final releases = [...channels, ...versions];
if (master != null) {
// Master goes first
releases.insert(0, master);
}

return releases;
return {for (var release in releases) release.name: release};
}

/// Returns all releases and channels that are cached
List<ReleaseDto> get allCached {
List<ReleaseDto> get all {
// Only get unique cached releases
// Some releases replicate across channels
// They can only be installed once and conflict
Expand Down Expand Up @@ -148,20 +145,15 @@ final releasesStateProvider = Provider<AppReleasesState>((ref) {
releasesState.versions.add(version);
}

/// Create a map with all the versions
final allVersions = [...releasesState.versions, ...releasesState.channels];
releasesState.allMap = {
for (var version in allVersions) version.name: version
};

return releasesState;
});

final getVersionProvider =
Provider.family<ReleaseDto, String>((ref, versionName) {
final state = ref.watch(releasesStateProvider);
return state.allMap[versionName];
});
final getVersionProvider = Provider.family<ReleaseDto, String>(
(ref, versionName) {
final state = ref.watch(releasesStateProvider);
return state.allMap[versionName];
},
);

enum Filter {
beta,
Expand Down
8 changes: 4 additions & 4 deletions lib/src/modules/sandbox/sandbox.screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class SandboxScreen extends HookWidget {
final selectedRelease = useState<ReleaseDto>(null);

useEffect(() {
if (selectedRelease.value == null && releases.allCached.isNotEmpty) {
selectedRelease.value = releases.allCached[0];
if (selectedRelease.value == null && releases.all.isNotEmpty) {
selectedRelease.value = releases.all[0];
}
return;
}, []);
Expand Down Expand Up @@ -80,15 +80,15 @@ class SandboxScreen extends HookWidget {
ListTile(
dense: true,
title: const Text('Releases'),
subtitle: Text('${releases.allCached.length} versions'),
subtitle: Text('${releases.all.length} versions'),
),
const Divider(height: 1),
Expanded(
child: CupertinoScrollbar(
child: Padding(
padding: const EdgeInsets.all(15.0),
child: ListView(
children: releases.allCached.map(
children: releases.all.map(
(version) {
if (version.name == selectedRelease.value?.name) {
return Padding(
Expand Down
9 changes: 1 addition & 8 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,6 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
effective_dart:
dependency: "direct dev"
description:
name: effective_dart
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.1"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -598,7 +591,7 @@ packages:
source: hosted
version: "2.0.0"
pedantic:
dependency: transitive
dependency: "direct dev"
description:
name: pedantic
url: "https://pub.dartlang.org"
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter
pedantic: ^1.11.0
build_runner: ^2.0.3
effective_dart: ^1.3.1
hive_generator: ^1.1.0
msix: ^2.1.1
build_version: ^2.0.3
Expand Down

0 comments on commit b9d0c5d

Please sign in to comment.