Skip to content

Commit

Permalink
implemented free license radio (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
numa08 authored Dec 19, 2023
1 parent 6d13065 commit 85f9232
Show file tree
Hide file tree
Showing 17 changed files with 474 additions and 179 deletions.
6 changes: 3 additions & 3 deletions app/radio_qth_map/lib/data/amateur_radio_band.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ class _$AmateurRadioBandInfoBandImpl implements _AmateurRadioBandInfoBand {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AmateurRadioBandInfoBandImpl &&
Expand Down Expand Up @@ -331,7 +331,7 @@ class _$AmateureRadioBandInfoFrequencyImpl
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AmateureRadioBandInfoFrequencyImpl &&
Expand Down Expand Up @@ -511,7 +511,7 @@ class _$AmateureRadioBandInfoBandAndFrequencyImpl
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AmateureRadioBandInfoBandAndFrequencyImpl &&
Expand Down
18 changes: 18 additions & 0 deletions app/radio_qth_map/lib/data/free_license_radio_mode.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

enum FreeLicenseRadioMode {
/// 特小
personalUse,
Expand All @@ -11,3 +14,18 @@ enum FreeLicenseRadioMode {
/// 市民ラジオ
citizensBand,
}

extension FreeLicenseRadioModeExtension on FreeLicenseRadioMode {
String localizedDescription(BuildContext context) {
switch (this) {
case FreeLicenseRadioMode.personalUse:
return AppLocalizations.of(context)!.personal_use;
case FreeLicenseRadioMode.lcr:
return AppLocalizations.of(context)!.lcr;
case FreeLicenseRadioMode.dcr:
return AppLocalizations.of(context)!.dcr;
case FreeLicenseRadioMode.citizensBand:
return AppLocalizations.of(context)!.citizens_band;
}
}
}
33 changes: 33 additions & 0 deletions app/radio_qth_map/lib/data/license_type.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import 'package:flutter/material.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';

/// ライセンス形態
enum LicenseType {
/// アマチュア無線
amateurRadio,

/// フリラー
free,
}

extension LicenseTypeExtension on LicenseType {
/// 説明用テキスト
String localizedDescription(BuildContext context) {
switch (this) {
case LicenseType.amateurRadio:
return AppLocalizations.of(context)!.ham;
case LicenseType.free:
return AppLocalizations.of(context)!.free_license;
}
}

/// アイコン
IconData get icon {
switch (this) {
case LicenseType.amateurRadio:
return Icons.radio;
case LicenseType.free:
return Icons.wifi;
}
}
}
4 changes: 2 additions & 2 deletions app/radio_qth_map/lib/data/location.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ class _$LocationLatLngImpl implements _LocationLatLng {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LocationLatLngImpl &&
Expand Down Expand Up @@ -306,7 +306,7 @@ class _$LocationGridLocatorImpl implements _LocationGridLocator {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$LocationGridLocatorImpl &&
Expand Down
2 changes: 1 addition & 1 deletion app/radio_qth_map/lib/data/operation.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class _$OperationImpl implements _Operation {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$OperationImpl &&
Expand Down
8 changes: 6 additions & 2 deletions app/radio_qth_map/lib/data/operation_info.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// ignore_for_file: invalid_annotation_target

import 'package:flutter/material.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:radio_qth_map/data/amateur_radio_band.dart';
import 'package:radio_qth_map/data/amateur_radio_mode.dart';
Expand Down Expand Up @@ -32,6 +33,9 @@ sealed class OperationInfo with _$OperationInfo {

/// モード
required FreeLicenseRadioMode mode,

/// チャンネル
int? channel,
}) = FreeLicenseRadioOperationInfo;

factory OperationInfo.fromJson(
Expand All @@ -45,7 +49,7 @@ sealed class OperationInfo with _$OperationInfo {

extension OperationInfoExtension on OperationInfo {
/// 説明用テキスト
String get description {
String localizedDescription(BuildContext context) {
switch (this) {
case AmateurRadioOperationInfo(
id: _,
Expand All @@ -58,7 +62,7 @@ extension OperationInfoExtension on OperationInfo {
id: _,
mode: final mode,
):
return 'Mode: ${mode.toString()}';
return 'Mode: ${mode.localizedDescription(context)}';
}
}
}
65 changes: 44 additions & 21 deletions app/radio_qth_map/lib/data/operation_info.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ mixin _$OperationInfo {
required TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)
amateur,
required TResult Function(String? id, FreeLicenseRadioMode mode)
required TResult Function(
String? id, FreeLicenseRadioMode mode, int? channel)
freeLicense,
}) =>
throw _privateConstructorUsedError;
Expand All @@ -48,15 +49,17 @@ mixin _$OperationInfo {
TResult? Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult? Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult? Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
}) =>
throw _privateConstructorUsedError;
@optionalTypeArgs
TResult maybeWhen<TResult extends Object?>({
TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
required TResult orElse(),
}) =>
throw _privateConstructorUsedError;
Expand Down Expand Up @@ -220,7 +223,7 @@ class _$AmateurRadioOperationInfoImpl implements AmateurRadioOperationInfo {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$AmateurRadioOperationInfoImpl &&
Expand Down Expand Up @@ -248,7 +251,8 @@ class _$AmateurRadioOperationInfoImpl implements AmateurRadioOperationInfo {
required TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)
amateur,
required TResult Function(String? id, FreeLicenseRadioMode mode)
required TResult Function(
String? id, FreeLicenseRadioMode mode, int? channel)
freeLicense,
}) {
return amateur(id, mode, band, powerOutput);
Expand All @@ -260,7 +264,8 @@ class _$AmateurRadioOperationInfoImpl implements AmateurRadioOperationInfo {
TResult? Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult? Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult? Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
}) {
return amateur?.call(id, mode, band, powerOutput);
}
Expand All @@ -271,7 +276,8 @@ class _$AmateurRadioOperationInfoImpl implements AmateurRadioOperationInfo {
TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
required TResult orElse(),
}) {
if (amateur != null) {
Expand Down Expand Up @@ -356,7 +362,7 @@ abstract class _$$FreeLicenseRadioOperationInfoImplCopyWith<$Res>
__$$FreeLicenseRadioOperationInfoImplCopyWithImpl<$Res>;
@override
@useResult
$Res call({String? id, FreeLicenseRadioMode mode});
$Res call({String? id, FreeLicenseRadioMode mode, int? channel});
}

/// @nodoc
Expand All @@ -374,6 +380,7 @@ class __$$FreeLicenseRadioOperationInfoImplCopyWithImpl<$Res>
$Res call({
Object? id = freezed,
Object? mode = null,
Object? channel = freezed,
}) {
return _then(_$FreeLicenseRadioOperationInfoImpl(
id: freezed == id
Expand All @@ -384,6 +391,10 @@ class __$$FreeLicenseRadioOperationInfoImplCopyWithImpl<$Res>
? _value.mode
: mode // ignore: cast_nullable_to_non_nullable
as FreeLicenseRadioMode,
channel: freezed == channel
? _value.channel
: channel // ignore: cast_nullable_to_non_nullable
as int?,
));
}
}
Expand All @@ -393,7 +404,7 @@ class __$$FreeLicenseRadioOperationInfoImplCopyWithImpl<$Res>
class _$FreeLicenseRadioOperationInfoImpl
implements FreeLicenseRadioOperationInfo {
const _$FreeLicenseRadioOperationInfoImpl(
{this.id, required this.mode, final String? $type})
{this.id, required this.mode, this.channel, final String? $type})
: $type = $type ?? 'freeLicense';

factory _$FreeLicenseRadioOperationInfoImpl.fromJson(
Expand All @@ -408,26 +419,31 @@ class _$FreeLicenseRadioOperationInfoImpl
@override
final FreeLicenseRadioMode mode;

/// チャンネル
@override
final int? channel;

@JsonKey(name: 'runtimeType')
final String $type;

@override
String toString() {
return 'OperationInfo.freeLicense(id: $id, mode: $mode)';
return 'OperationInfo.freeLicense(id: $id, mode: $mode, channel: $channel)';
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$FreeLicenseRadioOperationInfoImpl &&
(identical(other.id, id) || other.id == id) &&
(identical(other.mode, mode) || other.mode == mode));
(identical(other.mode, mode) || other.mode == mode) &&
(identical(other.channel, channel) || other.channel == channel));
}

@JsonKey(ignore: true)
@override
int get hashCode => Object.hash(runtimeType, id, mode);
int get hashCode => Object.hash(runtimeType, id, mode, channel);

@JsonKey(ignore: true)
@override
Expand All @@ -443,10 +459,11 @@ class _$FreeLicenseRadioOperationInfoImpl
required TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)
amateur,
required TResult Function(String? id, FreeLicenseRadioMode mode)
required TResult Function(
String? id, FreeLicenseRadioMode mode, int? channel)
freeLicense,
}) {
return freeLicense(id, mode);
return freeLicense(id, mode, channel);
}

@override
Expand All @@ -455,9 +472,10 @@ class _$FreeLicenseRadioOperationInfoImpl
TResult? Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult? Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult? Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
}) {
return freeLicense?.call(id, mode);
return freeLicense?.call(id, mode, channel);
}

@override
Expand All @@ -466,11 +484,12 @@ class _$FreeLicenseRadioOperationInfoImpl
TResult Function(String? id, AmateurRadioMode? mode,
AmateurRadioBandInfo band, double? powerOutput)?
amateur,
TResult Function(String? id, FreeLicenseRadioMode mode)? freeLicense,
TResult Function(String? id, FreeLicenseRadioMode mode, int? channel)?
freeLicense,
required TResult orElse(),
}) {
if (freeLicense != null) {
return freeLicense(id, mode);
return freeLicense(id, mode, channel);
}
return orElse();
}
Expand Down Expand Up @@ -516,8 +535,9 @@ class _$FreeLicenseRadioOperationInfoImpl

abstract class FreeLicenseRadioOperationInfo implements OperationInfo {
const factory FreeLicenseRadioOperationInfo(
{final String? id, required final FreeLicenseRadioMode mode}) =
_$FreeLicenseRadioOperationInfoImpl;
{final String? id,
required final FreeLicenseRadioMode mode,
final int? channel}) = _$FreeLicenseRadioOperationInfoImpl;

factory FreeLicenseRadioOperationInfo.fromJson(Map<String, dynamic> json) =
_$FreeLicenseRadioOperationInfoImpl.fromJson;
Expand All @@ -530,6 +550,9 @@ abstract class FreeLicenseRadioOperationInfo implements OperationInfo {

/// モード
FreeLicenseRadioMode get mode;

/// チャンネル
int? get channel;
@override
@JsonKey(ignore: true)
_$$FreeLicenseRadioOperationInfoImplCopyWith<
Expand Down
2 changes: 2 additions & 0 deletions app/radio_qth_map/lib/data/operation_info.g.dart

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

4 changes: 2 additions & 2 deletions app/radio_qth_map/lib/data/qso.freezed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class _$QsoImpl implements _Qso {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$QsoImpl &&
Expand Down Expand Up @@ -486,7 +486,7 @@ class _$QsoWithOperationImpl implements _QsoWithOperation {
}

@override
bool operator ==(dynamic other) {
bool operator ==(Object other) {
return identical(this, other) ||
(other.runtimeType == runtimeType &&
other is _$QsoWithOperationImpl &&
Expand Down
Loading

0 comments on commit 85f9232

Please sign in to comment.