Skip to content

Commit

Permalink
fix: デザイン修正
Browse files Browse the repository at this point in the history
  • Loading branch information
YumNumm committed Jun 14, 2024
1 parent b610954 commit 0c3f558
Show file tree
Hide file tree
Showing 10 changed files with 776 additions and 91 deletions.
42 changes: 13 additions & 29 deletions app/lib/core/component/container/bordered_container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,8 @@ class BorderedContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
if (onPressed != null) {
return Ink(
child: Card(
elevation: elevation,
color: accentColor ?? theme.cardColor,
// border
shape: RoundedRectangleBorder(
side: BorderSide(
color: theme.colorScheme.onSurface,
width: 0,
),
borderRadius: borderRadius,
),
margin: margin,
clipBehavior: Clip.antiAlias,
child: InkWell(
onTap: onPressed,
child: Padding(
padding: padding,
child: child,
),
),
),
);
}

return Card(
final card = Card(
clipBehavior: Clip.antiAlias,
elevation: elevation,
color: accentColor ?? theme.colorScheme.surfaceContainer,
Expand All @@ -63,10 +38,19 @@ class BorderedContainer extends StatelessWidget {
borderRadius: borderRadius,
),
margin: margin,
child: Padding(
padding: padding,
child: child,
child: InkWell(
onTap: onPressed,
child: Padding(
padding: padding,
child: child,
),
),
);
if (onPressed != null) {
return Ink(
child: card,
);
}
return card;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ class KmoniMaintenanceWidget extends ConsumerWidget {
accentColor: data.type == KmoniMaintenanceMessageType.highLight
? Colors.orangeAccent.withOpacity(0.2)
: null,
elevation: 1,
margin: const EdgeInsets.symmetric(
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
Expand Down
67 changes: 31 additions & 36 deletions app/lib/feature/home/component/eew/eew_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,16 @@ class EewWidgets extends ConsumerWidget {
@override
Widget build(BuildContext context, WidgetRef ref) {
final state = ref.watch(eewAliveTelegramProvider) ?? [];

final body = LayoutBuilder(
builder: (context, constraints) {
return AnimatedSwitcher(
duration: const Duration(milliseconds: 250),
child: Column(
children: state.reversed
.mapIndexed(
(index, element) => EewWidget(
eew: element,
index: (state.length > 1) ? '${index + 1}' : null,
),
)
.toList(),
),
);
},
return Column(
children: state.reversed
.mapIndexed(
(index, element) => EewWidget(
eew: element,
index: (state.length > 1) ? '${index + 1}' : null,
),
)
.toList(),
);
return body;
}
}

Expand All @@ -59,25 +50,22 @@ class EewWidget extends ConsumerWidget {
final colorTheme = theme.colorScheme;
final intensityColorScheme = ref.watch(intensityColorProvider);
if (eew.isCanceled) {
return Padding(
padding: const EdgeInsets.all(8),
child: Card(
margin: const EdgeInsets.all(4),
elevation: 1,
shadowColor: Colors.transparent,
// 角丸にして Border
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: BorderSide(
color: theme.dividerColor.withOpacity(0.6),
width: 0,
),
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(eew.headline ?? '先ほどの緊急地震速報は取り消されました'),
return BorderedContainer(
elevation: 1,
margin: const EdgeInsets.symmetric(
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
child: Center(
child: Padding(
padding: const EdgeInsets.all(8),
child: Text(eew.headline ?? '先ほどの緊急地震速報は取り消されました'),
),
),
);
Expand Down Expand Up @@ -336,6 +324,13 @@ class EewWidget extends ConsumerWidget {
]
: null;
final card = BorderedContainer(
elevation: 1,
margin: const EdgeInsets.symmetric(
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: EdgeInsets.zero,
accentColor: backgroundColor.withOpacity(0.3),
child: Padding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,22 @@ class ParameterLoaderWidget extends HookConsumerWidget {
key: ValueKey('non'),
),
),
_ => const AnimatedSwitcher(
duration: Duration(milliseconds: 150),
_ => AnimatedSwitcher(
duration: const Duration(milliseconds: 150),
child: BorderedContainer(
key: ValueKey('loading'),
key: const ValueKey('loading'),
elevation: 1,
child: Row(
margin: const EdgeInsets.symmetric(
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 8,
),
child: const Row(
children: [
Text('観測点の情報を取得中...'),
SizedBox(width: 8),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ class EarthquakeHistorySheetWidget extends HookConsumerWidget {
return BorderedContainer(
elevation: 1,
margin: const EdgeInsets.symmetric(
horizontal: 12,
),
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
Expand Down
41 changes: 22 additions & 19 deletions app/lib/feature/home/component/sheet/update_widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,30 @@ class UpdateWidget extends HookConsumerWidget {

final state = ref.watch(appInformationProvider);
return switch (state) {
AsyncData(:final value) when value.hasUpdate => Ink(
child: InkWell(
onTap: () {
launchUrl(
value.downloadUrl ??
Uri.parse('https://eqmonitor.page.link/app'),
mode: LaunchMode.externalApplication,
);
},
child: BorderedContainer(
elevation: 1,
padding: const EdgeInsets.all(8),
child: ListTile(
title: Text(
'アプリの更新があります: v${value.latestVersion}',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: const Text('利用可能なアップデートがあります'),
trailing: const Icon(Icons.arrow_forward_ios),
AsyncData(:final value) when value.hasUpdate => BorderedContainer(
onPressed: () async => launchUrl(
value.downloadUrl ?? Uri.parse('https://eqmonitor.app'),
mode: LaunchMode.externalApplication,
),
elevation: 1,
margin: const EdgeInsets.symmetric(
horizontal: 12,
) +
const EdgeInsets.only(
bottom: 8,
),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 4,
),
child: ListTile(
tileColor: Colors.transparent,
title: Text(
'アプリの更新があります: v${value.latestVersion}',
style: const TextStyle(fontWeight: FontWeight.bold),
),
subtitle: const Text('利用可能なアップデートがあります'),
trailing: const Icon(Icons.arrow_forward_ios),
),
),
_ => const SizedBox.shrink(),
Expand Down
2 changes: 1 addition & 1 deletion app/lib/feature/home/view/home_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,6 @@ class _Sheet extends StatelessWidget {
children: [
const EewWidgets(),
const KmoniMaintenanceWidget(),
const ParameterLoaderWidget(),
const UpdateWidget(),
const _NotificationPermission(),
const EarthquakeHistorySheetWidget(),
Expand All @@ -448,6 +447,7 @@ class _Sheet extends StatelessWidget {
leading: const Icon(Icons.settings),
onTap: () => const SettingsRoute().push<void>(context),
),
const ParameterLoaderWidget(),
const SizedBox(height: 200),
],
),
Expand Down
38 changes: 38 additions & 0 deletions packages/eqapi_types/lib/model/v1/app_information.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'app_information.freezed.dart';
part 'app_information.g.dart';

@freezed
class AppInformation with _$AppInformation {
const factory AppInformation({
required PlatformAppInformation ios,
required PlatformAppInformation android,
}) = _AppInformation;

factory AppInformation.fromJson(Map<String, dynamic> json) =>
_$AppInformationFromJson(json);
}

@freezed
class PlatformAppInformation with _$PlatformAppInformation {
const factory PlatformAppInformation({
required AppVersion? latest,
required AppVersion? minimum,
required String? downloadUrl,
}) = _PlatformAppInformation;

factory PlatformAppInformation.fromJson(Map<String, dynamic> json) =>
_$PlatformAppInformationFromJson(json);
}

@freezed
class AppVersion with _$AppVersion {
const factory AppVersion({
required String version,
required String? message,
}) = _AppVersion;

factory AppVersion.fromJson(Map<String, dynamic> json) =>
_$AppVersionFromJson(json);
}
Loading

0 comments on commit 0c3f558

Please sign in to comment.