Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/presentation/home/bloc/weekly_schedules_bloc.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'package:collection/collection.dart';
import 'package:equatable/equatable.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:injectable/injectable.dart';
Expand Down
9 changes: 9 additions & 0 deletions lib/presentation/home/bloc/weekly_schedules_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ final class WeeklySchedulesState extends Equatable {

List<DateTime> get dates =>
schedules.map((schedule) => schedule.scheduleTime).toList();
ScheduleEntity? get todaySchedule => schedules
.where((schedule) {
final now = DateTime.now();
return schedule.scheduleTime.year == now.year &&
schedule.scheduleTime.month == now.month &&
schedule.scheduleTime.day == now.day;
})
.sortedBy((e) => e.scheduleTime)
.firstOrNull;

WeeklySchedulesState copyWith({
WeeklySchedulesStatus Function()? status,
Expand Down
66 changes: 32 additions & 34 deletions lib/presentation/home/components/todays_schedule_tile.dart
Original file line number Diff line number Diff line change
@@ -1,60 +1,58 @@
import 'package:flutter/material.dart';
import 'package:on_time_front/domain/entities/schedule_entity.dart';
import 'package:on_time_front/presentation/shared/constants/app_colors.dart';

class TodaysScheduleTile extends StatelessWidget {
const TodaysScheduleTile({super.key, this.schedule});

final ScheduleEntity? schedule;
Widget noSchedule(BuildContext context) {
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerLow,
borderRadius: BorderRadius.circular(11),
),
width: double.infinity,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 11.0, vertical: 16.0),
child: Text(
'약속이 없는 날이에요',
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.outlineVariant,
),
),
return Text(
'약속이 없는 날이에요',
style: theme.textTheme.bodyLarge?.copyWith(
color: theme.colorScheme.outlineVariant,
),
);
}

Widget scheduleExists(BuildContext context) {
return Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
'${schedule!.scheduleTime.hour > 12 ? '오후' : '오전'} ${schedule!.scheduleTime.hour % 12}시 ${schedule!.scheduleTime.minute}분',
style: TextStyle(color: AppColors.white),
),
Text(
schedule!.scheduleName,
style: TextStyle(color: AppColors.white),
),
SizedBox(height: 8.0),
// - 시간 - 분 전
Text(
'${schedule!.scheduleTime.difference(DateTime.now()).inHours}시간 ${schedule!.scheduleTime.difference(DateTime.now()).inMinutes % 60}분 전',
style: TextStyle(color: AppColors.white),
),
],
);
}

@override
Widget build(BuildContext context) {
final theme = Theme.of(context);
return Container(
decoration: BoxDecoration(
color: theme.colorScheme.surfaceContainerLow,
color: schedule == null
? theme.colorScheme.surfaceContainerLow
: theme.colorScheme.primary,
borderRadius: BorderRadius.circular(11),
),
width: double.infinity,
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 11.0, vertical: 16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
schedule!.scheduleName,
style: theme.textTheme.bodyLarge,
),
SizedBox(height: 8.0),
Text(
schedule!.place.placeName,
style: theme.textTheme.bodySmall,
),
],
),
child: schedule == null ? noSchedule(context) : scheduleExists(context),
),
);
}

@override
Widget build(BuildContext context) {
return schedule == null ? noSchedule(context) : scheduleExists(context);
}
}
Loading