Skip to content

Commit

Permalink
v13
Browse files Browse the repository at this point in the history
  • Loading branch information
TruFelix committed Jan 14, 2023
1 parent d76d84e commit 17d8b66
Show file tree
Hide file tree
Showing 11 changed files with 130 additions and 44 deletions.
2 changes: 1 addition & 1 deletion example/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ android {
}

defaultConfig {
applicationId "dev.wanke.remind_timetable.example"
applicationId "at.betta.remind.timetable.example"
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.wankeremind_timetable.example">
package="at.betta.remind.timetable.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.wanke.remind_timetable.example">
package="at.betta.remind.timetable.example">
<application
android:label="Timetable example"
android:name="${applicationName}"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.wanke.remind_timetable.example
package at.betta.remind.timetable.example

import io.flutter.embedding.android.FlutterActivity

Expand Down
2 changes: 1 addition & 1 deletion example/android/app/src/profile/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="dev.wanke.remind_timetable.example">
package="at.betta.remind.timetable.example">
<!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc.
-->
Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ packages:
path: ".."
relative: true
source: path
version: "1.0.0-alpha.10"
version: "1.0.0-alpha.13"
sensors_plus:
dependency: transitive
description:
Expand Down Expand Up @@ -400,5 +400,5 @@ packages:
source: hosted
version: "3.0.1"
sdks:
dart: ">=2.18.0 <3.0.0"
dart: ">=2.18.6 <3.0.0"
flutter: ">=3.0.0"
110 changes: 110 additions & 0 deletions lib/src/components/dividers.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import 'package:flutter/material.dart';

import '../config.dart';
import '../theme.dart';
import '../utils.dart';

/// A widget that displays horizontal dividers for a day.
///
/// via the [DividersStyle.interval] you can adjust how these get drawn
///
/// See also:
///
/// * [DividersStyle], which defines visual properties for this widget.
/// * [TimetableTheme] (and [TimetableConfig]), which provide styles to
/// descendant Timetable widgets.
class Dividers extends StatelessWidget {
const Dividers({
super.key,
required this.style,
this.child,
});

final DividersStyle style;
final Widget? child;

@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _DividersPainter(
style: style,
),
child: child,
);
}
}

/// Defines visual properties for [Dividers].
///
/// See also:
///
/// * [TimetableThemeData], which bundles the styles for all Timetable widgets.
@immutable
class DividersStyle {
factory DividersStyle(
BuildContext context, {
Color? color,
double? width,
Duration? interval,
}) {
final dividerBorderSide = Divider.createBorderSide(context);
return DividersStyle.raw(
color: color ?? dividerBorderSide.color,
width: width ?? dividerBorderSide.width,
interval: interval ?? 1.hours
);
}

const DividersStyle.raw({
required this.color,
required this.width,
required this.interval,
}) : assert(width >= 0);

final Color color;
final double width;
final Duration interval;

DividersStyle copyWith({Color? color, double? width, Duration? interval}) {
return DividersStyle.raw(
color: color ?? this.color,
width: width ?? this.width,
interval: interval ?? this.interval,
);
}

@override
int get hashCode => Object.hash(color, width);
@override
bool operator ==(Object other) {
return other is DividersStyle &&
color == other.color &&
width == other.width;
}
}

class _DividersPainter extends CustomPainter {
_DividersPainter({
required this.style,
}) : _paint = Paint()
..color = style.color
..strokeWidth = style.width;

final DividersStyle style;
final Paint _paint;

@override
void paint(Canvas canvas, Size size) {
final heightPerDivider = size.height / (1.days / style.interval);
final strokes = size.height ~/ heightPerDivider;

for (var dividerNumber = 0; dividerNumber < strokes; dividerNumber++) {
final y = dividerNumber * heightPerDivider;
canvas.drawLine(Offset(-8, y), Offset(size.width, y), _paint);
}
}

@override
bool shouldRepaint(_DividersPainter oldDelegate) =>
style != oldDelegate.style;
}
33 changes: 4 additions & 29 deletions lib/src/components/hour_dividers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
import '../config.dart';
import '../theme.dart';
import '../utils.dart';
import 'dividers.dart';

/// A widget that displays horizontal dividers between hours of a day.
///
Expand All @@ -23,10 +24,8 @@ class HourDividers extends StatelessWidget {

@override
Widget build(BuildContext context) {
return CustomPaint(
painter: _HourDividersPainter(
style: style ?? TimetableTheme.orDefaultOf(context).hourDividersStyle,
),
return Dividers(
style: DividersStyle(context, color: style?.color, width: style?.width, interval: 1.hours),
child: child,
);
}
Expand Down Expand Up @@ -74,28 +73,4 @@ class HourDividersStyle {
color == other.color &&
width == other.width;
}
}

class _HourDividersPainter extends CustomPainter {
_HourDividersPainter({
required this.style,
}) : _paint = Paint()
..color = style.color
..strokeWidth = style.width;

final HourDividersStyle style;
final Paint _paint;

@override
void paint(Canvas canvas, Size size) {
final heightPerHour = size.height / Duration.hoursPerDay;
for (final h in InternalDateTimeTimetable.innerDateHours) {
final y = h * heightPerHour;
canvas.drawLine(Offset(-8, y), Offset(size.width, y), _paint);
}
}

@override
bool shouldRepaint(_HourDividersPainter oldDelegate) =>
style != oldDelegate.style;
}
}
12 changes: 6 additions & 6 deletions lib/src/components/multi_date_content.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ class MultiDateContent<E extends Event> extends StatefulWidget {
final GlobalKey<MultiDateContentGeometry>? geometryKey;

@override
State<MultiDateContent<E>> createState() => _MultiDateContentState<E>();
State<MultiDateContent<E>> createState() => MultiDateContentState<E>();
}

class _MultiDateContentState<E extends Event>
class MultiDateContentState<E extends Event>
extends State<MultiDateContent<E>> {
late GlobalKey<MultiDateContentGeometry> geometryKey;
late bool wasGeometryKeyFromWidget;
Expand Down Expand Up @@ -83,7 +83,7 @@ class _MultiDateContentState<E extends Event>
child: TimeZoom(
child: HourDividers(
child: NowIndicator(
child: _MultiDateContentGeometryWidget(
child: MultiDateContentGeometryWidget(
key: geometryKey,
child: datePages,
),
Expand All @@ -94,8 +94,8 @@ class _MultiDateContentState<E extends Event>
}
}

class _MultiDateContentGeometryWidget extends StatefulWidget {
const _MultiDateContentGeometryWidget({
class MultiDateContentGeometryWidget extends StatefulWidget {
const MultiDateContentGeometryWidget({
required GlobalKey<MultiDateContentGeometry> key,
required this.child,
}) : super(key: key);
Expand All @@ -106,7 +106,7 @@ class _MultiDateContentGeometryWidget extends StatefulWidget {
MultiDateContentGeometry createState() => MultiDateContentGeometry._();
}

class MultiDateContentGeometry extends State<_MultiDateContentGeometryWidget> {
class MultiDateContentGeometry extends State<MultiDateContentGeometryWidget> {
MultiDateContentGeometry._();

@override
Expand Down
1 change: 1 addition & 0 deletions lib/timetable.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export 'src/components/date_dividers.dart';
export 'src/components/date_events.dart';
export 'src/components/date_header.dart';
export 'src/components/date_indicator.dart';
export 'src/components/dividers.dart';
export 'src/components/hour_dividers.dart';
export 'src/components/month_indicator.dart';
export 'src/components/month_widget.dart';
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: remind_timetable
description: ReMinds timetable
version: 1.0.0-alpha.10
version: 1.0.0-alpha.13
repository: https://github.com/Allistic/timetable

environment:
sdk: '>=2.17.0-266.8.beta <3.0.0'
sdk: '>=2.18.6 <3.0.0'
flutter: '>=2.13.0-0.4.pre'

dependencies:
Expand Down

0 comments on commit 17d8b66

Please sign in to comment.