Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kalender items besser unterscheidbar #178

Merged
merged 2 commits into from
Jul 5, 2024
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
105 changes: 12 additions & 93 deletions lib/home/calendar/calendar_body.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:animations/animations.dart';
import 'package:better_hm/home/calendar/calendar_service.dart';
import 'package:better_hm/home/calendar/detail_screen.dart';
import 'package:better_hm/home/calendar/components/multi_day_tile.dart';
import 'package:better_hm/home/calendar/components/tile.dart';
import 'package:better_hm/shared/extensions/extensions_context.dart';
import 'package:better_hm/shared/models/event_data.dart';
import 'package:better_hm/shared/prefs.dart';
Expand Down Expand Up @@ -57,9 +57,8 @@ class _CalendarBodyState extends ConsumerState<CalendarBody> {
controller: calendarController,
eventsController: eventsController,
viewConfiguration: currentViewConfiguration,
tileBuilder: (event, config) => _tileBuilder(event, config, context),
multiDayTileBuilder: (event, config) =>
_multiDayTileBuilder(event, config, context),
tileBuilder: _tileBuilder,
multiDayTileBuilder: _multiDayTileBuilder,
scheduleTileBuilder: _scheduleTileBuilder,
);
}
Expand Down Expand Up @@ -93,104 +92,24 @@ class _CalendarBodyState extends ConsumerState<CalendarBody> {
Widget _tileBuilder(
CustomCalendarEvent event,
TileConfiguration configuration,
BuildContext context,
) {
final colors = getColors(event, context);
return Padding(
padding: const EdgeInsets.only(right: 4),
child: OpenContainer(
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide.none,
),
closedColor: colors.$1,
openColor: context.theme.colorScheme.surface,
closedElevation: 0,
useRootNavigator: true,
openBuilder: (context, action) {
return CalendarDetailScreen(
key: ObjectKey(event),
event: event,
);
},
closedBuilder: (context, action) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
margin: EdgeInsets.zero,
elevation: 0,
color: configuration.tileType != TileType.ghost
? colors.$1
: colors.$1.withAlpha(100),
child: Padding(
padding: const EdgeInsets.only(left: 2),
child: configuration.tileType != TileType.ghost
? Text(
event.eventData?.component.summary?.value.value ??
"No title",
style: TextStyle(color: colors.$2),
softWrap: true,
)
: null,
),
);
},
),
return Tile(
event: event,
configuration: configuration,
colors: colors,
);
}

Widget _multiDayTileBuilder(
CustomCalendarEvent event,
MultiDayTileConfiguration configuration,
BuildContext context,
) {
final colors = getColors(event, context);
return Padding(
padding: const EdgeInsets.only(bottom: 2),
child: OpenContainer(
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
closedColor: colors.$1,
openColor: context.theme.colorScheme.surface,
closedElevation: 0,
useRootNavigator: true,
openBuilder: (context, action) {
return CalendarDetailScreen(event: event);
},
closedBuilder: (context, action) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: colors.$1),
),
margin: EdgeInsets.zero,
elevation: configuration.tileType == TileType.selected ? 8 : 0,
color: configuration.tileType == TileType.ghost
? colors.$1.withAlpha(100)
: colors.$1,
child: Padding(
padding: const EdgeInsets.only(left: 2),
child: Align(
alignment: Alignment.centerLeft,
child: configuration.tileType != TileType.ghost
? Text(
event.eventData?.component.summary?.value.value ??
"No title",
// style: TextStyle(color: colors.$2),
style: context.theme.textTheme.bodySmall?.copyWith(
color: colors.$2,
),
overflow: TextOverflow.clip,
softWrap: false,
)
: null,
),
),
);
},
),
return MultiDayTile(
event: event,
configuration: configuration,
colors: colors,
);
}

Expand Down
70 changes: 70 additions & 0 deletions lib/home/calendar/components/multi_day_tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:animations/animations.dart';
import 'package:better_hm/home/calendar/calendar_service.dart';
import 'package:better_hm/home/calendar/detail_screen.dart';
import 'package:better_hm/shared/extensions/extensions_context.dart';
import 'package:flutter/material.dart';
import 'package:kalender/kalender.dart';

class MultiDayTile extends StatelessWidget {
const MultiDayTile({
super.key,
required this.event,
required this.configuration,
required this.colors,
});

final CustomCalendarEvent event;
final MultiDayTileConfiguration configuration;

final (Color, Color) colors;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(bottom: 2, right: 4),
child: OpenContainer(
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
),
closedColor: colors.$1,
openColor: context.theme.colorScheme.surface,
closedElevation: 0,
useRootNavigator: true,
openBuilder: (context, action) {
return CalendarDetailScreen(event: event);
},
closedBuilder: (context, action) {
return Card(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide(color: colors.$1),
),
margin: EdgeInsets.zero,
elevation: configuration.tileType == TileType.selected ? 8 : 0,
color: configuration.tileType == TileType.ghost
? colors.$1.withAlpha(100)
: colors.$1,
child: Padding(
padding: const EdgeInsets.only(left: 4),
child: Align(
alignment: Alignment.centerLeft,
child: configuration.tileType != TileType.ghost
? Text(
event.eventData?.component.summary?.value.value ??
"No title",
// style: TextStyle(color: colors.$2),
style: context.theme.textTheme.bodySmall?.copyWith(
color: colors.$2,
),
overflow: TextOverflow.clip,
softWrap: false,
)
: null,
),
),
);
},
),
);
}
}
70 changes: 70 additions & 0 deletions lib/home/calendar/components/tile.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import 'package:animations/animations.dart';
import 'package:better_hm/home/calendar/calendar_service.dart';
import 'package:better_hm/home/calendar/detail_screen.dart';
import 'package:better_hm/shared/extensions/extensions_context.dart';
import 'package:flutter/material.dart';
import 'package:kalender/kalender.dart';

class Tile extends StatelessWidget {
const Tile({
super.key,
required this.event,
required this.configuration,
required this.colors,
});

final CustomCalendarEvent event;
final TileConfiguration configuration;

final (Color, Color) colors;

@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.only(right: 4),
child: OpenContainer(
closedShape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8),
side: BorderSide.none,
),
closedColor: colors.$1,
openColor: context.theme.colorScheme.surface,
closedElevation: 0,
useRootNavigator: true,
openBuilder: (context, action) {
return CalendarDetailScreen(
key: ObjectKey(event),
event: event,
);
},
closedBuilder: (context, action) {
return Container(
padding: const EdgeInsets.only(left: 6, top: 2),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(8),
color: configuration.tileType != TileType.ghost
? colors.$1
: colors.$1.withAlpha(100),
border: configuration.drawOutline
? Border.all(
color: context.theme.colorScheme.surface,
width: 2,
)
: null,
),
margin: EdgeInsets.zero,
child: configuration.tileType != TileType.ghost
? Text(
event.eventData?.component.summary?.value.value ??
"No title",
style: context.theme.textTheme.bodySmall
?.copyWith(color: colors.$2),
softWrap: true,
)
: null,
);
},
),
);
}
}
3 changes: 2 additions & 1 deletion lib/home/calendar/detail_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CalendarDetailScreen extends StatelessWidget {
body: ListView(
children: [
_TitleRow(event: event),
if (component.location != null)
if (component.location != null &&
component.location!.value.value.isNotEmpty)
_PropertyRow(
leading: const Icon(Icons.location_on_outlined),
label: Text(component.location!.value.value),
Expand Down