Skip to content

Commit

Permalink
add: 詳細画面
Browse files Browse the repository at this point in the history
  • Loading branch information
YumNumm committed Aug 3, 2024
1 parent e57f50a commit 0c0140c
Show file tree
Hide file tree
Showing 25 changed files with 1,736 additions and 268 deletions.
18 changes: 16 additions & 2 deletions app/lib/core/api/eq_api.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import 'package:dio/dio.dart';
import 'package:eqapi_client/eqapi_client.dart';
import 'package:eqmonitor/core/provider/dio_provider.dart';
import 'package:eqmonitor/core/provider/log/talker.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
import 'package:talker_dio_logger/talker_dio_logger_interceptor.dart';
import 'package:talker_dio_logger/talker_dio_logger_settings.dart';
import 'package:talker_flutter/talker_flutter.dart';

part 'eq_api.g.dart';

Expand All @@ -18,9 +22,19 @@ EqApi eqApi(EqApiRef ref) {
dio: dio,
objectsDio: Dio(
BaseOptions(
baseUrl: 'https://objects.eqmonitor.app',
baseUrl: 'https://object.eqmonitor.app',

),
)..interceptors.add(
TalkerDioLogger(
settings: TalkerDioLoggerSettings(
errorPen: AnsiPen()..red(),
requestPen: AnsiPen()..yellow(),
responsePen: AnsiPen()..green(),
),
talker: ref.watch(talkerProvider),
),
),
),
);
}

Expand Down
2 changes: 1 addition & 1 deletion app/lib/core/api/eq_api.g.dart

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

2 changes: 1 addition & 1 deletion app/lib/core/api/jma_parameter_api.g.dart

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

155 changes: 155 additions & 0 deletions app/lib/core/component/intenisty/jma_forecast_intensity_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,158 @@ class JmaForecastIntensityWidget extends ConsumerWidget {
);
}
}

class JmaForecastIntensityIcon extends ConsumerWidget {
const JmaForecastIntensityIcon({
required this.intensity,
required this.type,
this.customText,
super.key,
this.size = 50,
this.showSuffix = true,
});
final JmaForecastIntensity intensity;
final IntensityIconType type;
final double size;
final String? customText;
final bool showSuffix;

@override
Widget build(BuildContext context, WidgetRef ref) {
final intensityColorModel = ref.watch(intensityColorProvider);
final colorScheme = intensityColorModel.fromJmaForecastIntensity(intensity);
final (fg, bg) = (colorScheme.foreground, colorScheme.background);
// 震度の整数部分
final intensityMainText =
intensity.type.replaceAll('-', '').replaceAll('+', '');
// 震度の弱・強の表記
final suffix = intensity.type.contains('-')
? '-'
: intensity.type.contains('+')
? '+'
: '';
final intensitySubText = intensity.type.contains('-')
? '弱'
: intensity.type.contains('+')
? '強'
: '';
final borderColor = Color.lerp(
bg,
fg,
0.3,
)!;
return switch (type) {
IntensityIconType.small => SizedBox(
height: size,
width: size,
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: bg,
border: Border.all(
color: borderColor,
width: 5,
),
),
child:Center(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
intensityMainText,
style: TextStyle(
color: fg,
fontSize: 100,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
),
),
Text(
suffix,
style: TextStyle(
color: fg,
fontSize: 80,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
fontFamilyFallback: const [FontFamily.notoSansJP],
),
),
],
),
),
),
),
),
IntensityIconType.smallWithoutText => SizedBox(
height: size,
width: size,
child: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: bg,
border: Border.all(
color: borderColor,
width: 5,
),
),
),
),
IntensityIconType.filled => SizedBox(
height: size,
width: size,
child: DecoratedBox(
decoration: BoxDecoration(
color: bg,
// 角丸にする
borderRadius: BorderRadius.circular(size / 5),
),
child: Center(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: [
if (customText != null)
Text(
customText!,
style: TextStyle(
color: fg,
fontSize: 100,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
),
)
else ...[
Text(
intensityMainText,
style: TextStyle(
color: fg,
fontSize: 100,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
),
),
if (showSuffix)
Text(
intensitySubText,
style: TextStyle(
color: fg,
fontSize: 50,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
fontFamilyFallback: const [FontFamily.notoSansJP],
),
),
],
],
),
),
),
),
),
};
}
}
50 changes: 27 additions & 23 deletions app/lib/core/component/intenisty/jma_intensity_icon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,35 @@ class JmaIntensityIcon extends ConsumerWidget {
child: (intensity == JmaIntensity.fiveUpperNoInput)
? const SizedBox.shrink()
: Center(
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
intensityMainText,
style: TextStyle(
color: fg,
fontSize: 100,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
child: Padding(
padding: const EdgeInsets.all(2),
child: FittedBox(
fit: BoxFit.scaleDown,
child: Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
intensityMainText,
style: TextStyle(
color: fg,
fontSize: 100,
fontWeight: FontWeight.bold,
fontFamily: FontFamily.jetBrainsMono,
),
),
),
Text(
suffix,
style: TextStyle(
color: fg,
fontSize: 80,
fontWeight: FontWeight.w900,
fontFamily: FontFamily.jetBrainsMono,
fontFamilyFallback: const [FontFamily.notoSansJP],
Text(
suffix,
style: TextStyle(
color: fg,
fontSize: 80,
fontFamily: FontFamily.jetBrainsMono,
fontFamilyFallback: const [
FontFamily.notoSansJP,
],
),
),
),
],
],
),
),
),
),
Expand Down
4 changes: 1 addition & 3 deletions app/lib/core/provider/dio_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ Dio dio(DioRef ref) {
final dio = Dio(
BaseOptions(
headers: {
'user-agent': 'eqmonitor-${kIsWeb ? "web" : Platform.version}',
'x-operation-system-version':
kIsWeb ? 'web' : Platform.operatingSystemVersion,
'user-agent': 'eqmonitor',
if (authorization != null) 'authorization': authorization,
},
baseUrl: ref.watch(telegramUrlProvider).restApiUrl,
Expand Down
3 changes: 2 additions & 1 deletion app/lib/core/provider/map/map_style.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ class MapStyle {
},
'sprite': '',
'glyphs':
'https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf',
// 'https://orangemug.github.io/font-glyphs/glyphs/{fontstack}/{range}.pbf',
'https://glyphs.geolonia.com/{fontstack}/{range}.pbf',
'layers': [
{
'id': BaseLayer.background.name,
Expand Down
6 changes: 6 additions & 0 deletions app/lib/core/router/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:eqmonitor/feature/donation/ui/donation_executed_screen.dart';
import 'package:eqmonitor/feature/donation/ui/donation_screen.dart';
import 'package:eqmonitor/feature/earthquake_history/ui/earthquake_history_screen.dart';
import 'package:eqmonitor/feature/earthquake_history_details/screen/earthquake_history_details.dart';
import 'package:eqmonitor/feature/earthquake_history_early/ui/earthquake_history_early_details_screen.dart';
import 'package:eqmonitor/feature/earthquake_history_early/ui/earthquake_history_early_screen.dart';
import 'package:eqmonitor/feature/home/view/home_view.dart';
import 'package:eqmonitor/feature/information_history/page/information_history_page.dart';
Expand Down Expand Up @@ -141,6 +142,11 @@ class InformationHistoryDetailsRoute extends GoRouteData {
routes: [
TypedGoRoute<EarthquakeHistoryEarlyRoute>(
path: 'earthquake-history-early',
routes: [
TypedGoRoute<EarthquakeHistoryEarlyDetailsRoute>(
path: 'details/:id',
),
],
),
],
)
Expand Down
27 changes: 27 additions & 0 deletions app/lib/core/router/router.g.dart

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

Original file line number Diff line number Diff line change
Expand Up @@ -785,16 +785,18 @@ class _StationAction extends _Action {
'station-intensity-symbol',
SymbolLayerProperties(
textField: ['get', 'name'],
textSize: 12,
textSize: 13,
textColor: Colors.black.toHexStringRGB(),
textHaloColor: Colors.white.toHexStringRGB(),
textHaloWidth: 0.5,
textHaloWidth: 2,
textFont: ['Noto Sans CJK JP Bold'],
textOffset: [
map_libre.Expressions.literal,
[0, 2],
],
),
sourceLayer: 'station-intensity',
minzoom: 10,
minzoom: 9,
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import 'package:eqapi_types/model/v1/earthquake_early.dart';
import 'package:eqmonitor/feature/earthquake_history_early/data/earthquake_history_early_repository.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'earthquake_history_early_details_notifier.g.dart';

@riverpod
Future<EarthquakeEarlyEvent> earthquakeHistoryEarlyEvent(
EarthquakeHistoryEarlyEventRef ref,
String id,
) =>
ref
.watch(earthquakeHistoryEarlyRepositoryProvider)
.fetchEarthquakeEarlyEvent(
id: id,
);
Loading

0 comments on commit 0c0140c

Please sign in to comment.