Skip to content

Commit

Permalink
Merge pull request #38 from kosukesaigusa/spot_difference
Browse files Browse the repository at this point in the history
fix: 赤丸の修正(再)
  • Loading branch information
kosukesaigusa authored Oct 1, 2023
2 parents e4d4200 + 5a3652a commit d2c4910
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions packages/hackathon_app/lib/spot_difference/ui/spot_difference.dart
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ class _SpotDifference extends HookConsumerWidget {
GestureDetector(
onLongPressStart: (details) {
// 現在地点と正解のリストを比較

for (final e in scaledAnswerPoints.value) {
final scaledThreshold =
threshold * size.value.height / defaultDifferenceSize;
Expand All @@ -288,22 +287,26 @@ class _SpotDifference extends HookConsumerWidget {
final distance =
(details.localPosition - scaledAnswerOffset).distance;
final isNearShowDifferenceOffset = distance < scaledThreshold;
print(details.localPosition);
print(isNearShowDifferenceOffset);

// 正解している場合、idを追加&円を描画
// 正解している場合
if (isNearShowDifferenceOffset) {
// 既に正解している箇所であれば処理を終了(不正解とまではしない)
if (completedPointIds.contains(e.pointId)) {
return;
}

// データの更新とお祝いポップアップの表示
ref.read(spotDifferenceServiceProvider).addPoint(
roomId: roomId,
answerId: answerId,
pointId: e.pointId,
);

// 正解した場合、そのOffset周りに円を描画
ref.read(spotDifferenceControllerProvider).celebrate();
return;
}
}
// 不正解の場合、制限をかける
ref.read(spotDifferenceControllerProvider).restrict();
},
child: GenericImage.rectangle(
Expand All @@ -327,6 +330,7 @@ class _SpotDifference extends HookConsumerWidget {
}
}

/// 正解した箇所に表示される赤丸
class _PositionedCircle extends StatelessWidget {
const _PositionedCircle({
required this.dx,
Expand All @@ -343,23 +347,16 @@ class _PositionedCircle extends StatelessWidget {
return Positioned(
left: dx - diameter / 2,
top: dy - diameter / 2,
child: ShaderMask(
shaderCallback: (bounds) {
return const RadialGradient(
colors: [Colors.transparent, Colors.red],
stops: [
0.85,
0.9,
],
).createShader(bounds);
},
child: Container(
width: diameter,
height: diameter,
decoration: const BoxDecoration(
child: Container(
width: diameter,
height: diameter,
decoration: BoxDecoration(
color: Colors.transparent,
border: Border.all(
color: Colors.red,
shape: BoxShape.circle,
width: 2,
),
shape: BoxShape.circle,
),
),
);
Expand Down

0 comments on commit d2c4910

Please sign in to comment.