Skip to content

Commit

Permalink
feat: Fixes issue #412: ✨ Add support for RTL directionality
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-jitiya-simform committed Feb 14, 2025
1 parent 2759702 commit ff764ee
Show file tree
Hide file tree
Showing 25 changed files with 711 additions and 367 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Adds clear method to `EventController`.
- Adds `onEventTapDetails`, `onEventDoubleTapDetails` & `onEventLongTapDetails` gesture recognizers to get tap details. [#390](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/390)
- Adds support of directionality. [#412](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/issues/412)

# [1.4.0 - 7 Jan 2025](https://github.com/SimformSolutionsPvtLtd/flutter_calendar_view/tree/1.4.0)

Expand Down
23 changes: 22 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,30 @@ WeekView(
],
);
```

Above code will create `WeekView` with only five days, from monday to friday.

### Support for RTL
Wrap your widget with `Directionality` widget and use `textDirection` to give RTL or LTR direction.

```dart
Directionality(
textDirection: TextDirection.rtl,
child: ResponsiveWidget(
webWidget: WebHomePage(
selectedView: CalendarView.week,
),
mobileWidget: Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
elevation: 8,
onPressed: () => context.pushRoute(CreateEventPage()),
),
body: WeekViewWidget(),
),
),
);
```

## Main Contributors

<table>
Expand Down
1 change: 1 addition & 0 deletions example/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class AppConstants {
AppConstants._();

static final List<String> weekTitles = ['M', 'T', 'W', 'T', 'F', 'S', 'S'];
static final ltr = '\u202A'; // Use this to force text direction to LTR

static OutlineInputBorder inputBorder = OutlineInputBorder(
borderRadius: BorderRadius.circular(7),
Expand Down
80 changes: 45 additions & 35 deletions example/lib/pages/create_event_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,50 +6,60 @@ import '../extension.dart';
import '../widgets/add_event_form.dart';

class CreateEventPage extends StatelessWidget {
const CreateEventPage({super.key, this.event});
const CreateEventPage({
super.key,
this.event,
this.directionality = TextDirection.ltr,
});

final CalendarEventData? event;
final TextDirection directionality;

@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
centerTitle: false,
leading: IconButton(
onPressed: context.pop,
icon: Icon(
Icons.arrow_back,
color: AppColors.black,
return Directionality(
textDirection: directionality,
child: Scaffold(
appBar: AppBar(
elevation: 0,
backgroundColor: Theme.of(context).scaffoldBackgroundColor,
centerTitle: false,
leading: IconButton(
onPressed: context.pop,
icon: Icon(
Icons.arrow_back,
color: AppColors.black,
),
),
),
title: Text(
event == null ? "Create New Event" : "Update Event",
style: TextStyle(
color: AppColors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold,
title: Text(
event == null ? "Create New Event" : "Update Event",
style: TextStyle(
color: AppColors.black,
fontSize: 20.0,
fontWeight: FontWeight.bold,
),
),
),
),
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Padding(
padding: EdgeInsets.all(20.0),
child: AddOrEditEventForm(
onEventAdd: (newEvent) {
if (this.event != null) {
CalendarControllerProvider.of(context)
.controller
.update(this.event!, newEvent);
} else {
CalendarControllerProvider.of(context).controller.add(newEvent);
}
body: SingleChildScrollView(
physics: ClampingScrollPhysics(),
child: Padding(
padding: EdgeInsets.all(20.0),
child: AddOrEditEventForm(
onEventAdd: (newEvent) {
if (this.event != null) {
CalendarControllerProvider.of(context)
.controller
.update(this.event!, newEvent);
} else {
CalendarControllerProvider.of(context)
.controller
.add(newEvent);
}

context.pop(true);
},
event: event,
context.pop(true);
},
event: event,
),
),
),
),
Expand Down
34 changes: 23 additions & 11 deletions example/lib/pages/day_view_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ import 'create_event_page.dart';
import 'web/web_home_page.dart';

class DayViewPageDemo extends StatefulWidget {
const DayViewPageDemo({super.key});
const DayViewPageDemo({
super.key,
this.directionality = TextDirection.ltr,
});

final TextDirection directionality;

@override
_DayViewPageDemoState createState() => _DayViewPageDemoState();
Expand All @@ -17,17 +22,24 @@ class DayViewPageDemo extends StatefulWidget {
class _DayViewPageDemoState extends State<DayViewPageDemo> {
@override
Widget build(BuildContext context) {
return ResponsiveWidget(
webWidget: WebHomePage(
selectedView: CalendarView.day,
),
mobileWidget: Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
elevation: 8,
onPressed: () => context.pushRoute(CreateEventPage()),
return Directionality(
textDirection: widget.directionality,
child: ResponsiveWidget(
webWidget: WebHomePage(
selectedView: CalendarView.day,
),
mobileWidget: Scaffold(
floatingActionButton: FloatingActionButton(
child: Icon(Icons.add),
elevation: 8,
onPressed: () => context.pushRoute(
CreateEventPage(
directionality: widget.directionality,
),
),
),
body: DayViewWidget(),
),
body: DayViewWidget(),
),
);
}
Expand Down
Loading

0 comments on commit ff764ee

Please sign in to comment.