Skip to content

Commit

Permalink
feat: add legalese to app info
Browse files Browse the repository at this point in the history
  • Loading branch information
khoadng committed Jun 24, 2023
1 parent 423d653 commit 19d068a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/boorus/core/pages/settings/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';

// Project imports:
import 'package:boorusama/boorus/core/provider.dart';
import 'package:boorusama/foundation/app_info.dart';
import 'package:boorusama/foundation/package_info.dart';

class AboutPage extends ConsumerWidget {
Expand All @@ -25,8 +26,11 @@ class AboutPage extends ConsumerWidget {
height: 64,
),
applicationVersion: packageInfo.version,
applicationLegalese: '\u{a9} 2020-2023 Nguyen Duc Khoa',
applicationLegalese: _legaleseFromAppInfo(appInfo),
applicationName: appInfo.appName,
);
}
}

String _legaleseFromAppInfo(AppInfo appInfo) =>
'\u{a9} ${appInfo.copyrightYearRange.start}-${appInfo.copyrightYearRange.end} ${appInfo.author}';
17 changes: 14 additions & 3 deletions lib/foundation/app_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ import 'package:flutter/services.dart';

const String _assetUrl = 'assets/information.json';

typedef YearRange = ({
int start,
int end,
});

class AppInfo {
const AppInfo({
AppInfo({
required this.discordUrl,
required this.githubUrl,
required this.appName,
required this.translationProjectUrl,
});
}) : copyrightYearRange = (
start: 2020,
end: DateTime.now().toUtc().year,
),
author = 'Nguyen Duc Khoa';

factory AppInfo.fromJson(Map<String, dynamic> json) => AppInfo(
discordUrl: json['discordUrl'],
Expand All @@ -21,7 +30,7 @@ class AppInfo {
translationProjectUrl: json['translationProjectUrl'],
);

static const empty = AppInfo(
static final empty = AppInfo(
discordUrl: '',
githubUrl: '',
appName: '',
Expand All @@ -32,6 +41,8 @@ class AppInfo {
final String githubUrl;
final String appName;
final String translationProjectUrl;
final YearRange copyrightYearRange;
final String author;
}

Future<AppInfo> getAppInfo() async {
Expand Down

0 comments on commit 19d068a

Please sign in to comment.