Skip to content

Commit

Permalink
♻️ refactor: RepoCountをtypedefからclassに変更
Browse files Browse the repository at this point in the history
Issue #145
  • Loading branch information
susatthi committed May 27, 2022
1 parent 54ccae4 commit 6fb1819
Show file tree
Hide file tree
Showing 11 changed files with 352 additions and 105 deletions.
10 changes: 1 addition & 9 deletions lib/domain/entities/repo.dart
Expand Up @@ -3,8 +3,8 @@
// found in the LICENSE file.

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:number_display/number_display.dart';

import 'values/repo_count.dart';
import 'values/repo_language.dart';

part 'repo.freezed.dart';
Expand Down Expand Up @@ -65,11 +65,3 @@ class Repo with _$Repo {
String? issuesUrl,
}) = _Repo;
}

/// カウントValueObject
typedef RepoCount = int;

extension RepoCountHelper on RepoCount {
/// 表示用のスター数(例:35432 => 35.4k)
String get display => createDisplay(length: 4)(this);
}
116 changes: 84 additions & 32 deletions lib/domain/entities/repo.freezed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions lib/domain/entities/values/repo_count.dart
@@ -0,0 +1,21 @@
// Copyright 2022 susatthi All rights reserved.
// Use of this source code is governed by a MIT license that can be
// found in the LICENSE file.

import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:number_display/number_display.dart';

part 'repo_count.freezed.dart';

/// カウント
@freezed
class RepoCount with _$RepoCount {
const factory RepoCount(
int value,
) = _RepoCount;
}

extension RepoCountHelper on RepoCount {
/// 表示用(例:35432 => 35.4k)
String get display => createDisplay(length: 4)(value);
}

0 comments on commit 6fb1819

Please sign in to comment.