mirror of
https://github.com/Iconica-Development/flutter_timetable.git
synced 2025-05-18 19:43:43 +02:00
feat: add ability to offset hours so table can span across midnight
This commit is contained in:
parent
f79ae93962
commit
dc338d4e37
8 changed files with 25 additions and 233 deletions
|
@ -22,3 +22,7 @@
|
|||
## [1.2.1] - 7 November 2023
|
||||
|
||||
* Fixed the assert on the [scrollTriggerOffset] and [scrollJumpToOffset].
|
||||
|
||||
## [1.3.0] - 8 November 2023
|
||||
|
||||
* Add the option for setting an offset for the hours so that the first hour is not 00:00 but 08:00 for example and the last hour can be after 24:00.
|
||||
|
|
5
example/.gitignore
vendored
5
example/.gitignore
vendored
|
@ -19,7 +19,7 @@ migrate_working_dir/
|
|||
# The .vscode folder contains launch configuration and tasks you configure in
|
||||
# VS Code which you may wish to be included in version control, so this line
|
||||
# is commented out by default.
|
||||
#.vscode/
|
||||
.vscode/
|
||||
|
||||
# Flutter/Dart/Pub related
|
||||
**/doc/api/
|
||||
|
@ -45,3 +45,6 @@ app.*.map.json
|
|||
/android/app/debug
|
||||
/android/app/profile
|
||||
/android/app/release
|
||||
|
||||
pubspec.lock
|
||||
.metadata
|
|
@ -1,30 +0,0 @@
|
|||
# This file tracks properties of this Flutter project.
|
||||
# Used by Flutter tool to assess capabilities and perform upgrades etc.
|
||||
#
|
||||
# This file should be version controlled and should not be manually edited.
|
||||
|
||||
version:
|
||||
revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
|
||||
channel: "stable"
|
||||
|
||||
project_type: app
|
||||
|
||||
# Tracks metadata for the flutter migrate command
|
||||
migration:
|
||||
platforms:
|
||||
- platform: root
|
||||
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
- platform: web
|
||||
create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
|
||||
|
||||
# User provided section
|
||||
|
||||
# List of Local paths (relative to this file) that should be
|
||||
# ignored by the migrate tool.
|
||||
#
|
||||
# Files that are not part of the templates will be ignored by default.
|
||||
unmanaged_files:
|
||||
- 'lib/main.dart'
|
||||
- 'ios/Runner.xcodeproj/project.pbxproj'
|
|
@ -149,9 +149,10 @@ class _TimetableDemoState extends State<TimetableDemo> {
|
|||
child: Timetable(
|
||||
onOverScroll: () {},
|
||||
onUnderScroll: () {},
|
||||
hoursOffset: 6,
|
||||
size: Size(size.width, size.height * 0.64),
|
||||
tableDirection: _horizontal ? Axis.horizontal : Axis.vertical,
|
||||
startHour: 3,
|
||||
startHour: 0,
|
||||
endHour: 24,
|
||||
timeBlocks: blocks,
|
||||
scrollController: _scrollController,
|
||||
|
|
|
@ -1,196 +0,0 @@
|
|||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
characters:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: characters
|
||||
sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.0"
|
||||
clock:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: clock
|
||||
sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.17.2"
|
||||
cupertino_icons:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: cupertino_icons
|
||||
sha256: e35129dc44c9118cee2a5603506d823bab99c68393879edb440e0090d07586be
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
fake_async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: fake_async
|
||||
sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.1"
|
||||
flutter:
|
||||
dependency: "direct main"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: flutter_lints
|
||||
sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
flutter_test:
|
||||
dependency: "direct dev"
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
flutter_timetable:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "1.1.0"
|
||||
lints:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: lints
|
||||
sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16"
|
||||
material_color_utilities:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: material_color_utilities
|
||||
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.1"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.8.3"
|
||||
sky_engine:
|
||||
dependency: transitive
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.99"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: c3c7d8edb15bee7f0f74debd4b9c5f3c2ea86766fe4178eb2a18eb30a0bdaed5
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.0"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: "83615bee9045c1d322bbbd1ba209b7a749c2cbcdcb3fdd1df8eb488b3279c1c8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.0"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.1.4-beta"
|
||||
sdks:
|
||||
dart: ">=3.1.0-185.0.dev <4.0.0"
|
||||
flutter: ">=1.17.0"
|
|
@ -25,6 +25,7 @@ class Timetable extends StatefulWidget {
|
|||
this.initialScrollTime,
|
||||
this.scrollController,
|
||||
this.scrollPhysics,
|
||||
this.hoursOffset = 0,
|
||||
this.startHour = 0,
|
||||
this.endHour = 24,
|
||||
this.blockDimension = 50,
|
||||
|
@ -55,6 +56,10 @@ class Timetable extends StatefulWidget {
|
|||
/// Hour at which the timetable ends.
|
||||
final int endHour;
|
||||
|
||||
/// The time offset to increase all hour labels with
|
||||
/// this is used to make the timetable start at a different time and go past midnight.
|
||||
final int hoursOffset;
|
||||
|
||||
/// The time blocks that will be displayed in the timetable.
|
||||
final List<TimeBlock> timeBlocks;
|
||||
|
||||
|
@ -170,6 +175,7 @@ class _TimetableState extends State<Timetable> {
|
|||
alignment: Alignment.topLeft,
|
||||
children: [
|
||||
table.Table(
|
||||
hoursOffset: widget.hoursOffset,
|
||||
tableDirection: widget.tableDirection,
|
||||
startHour: widget.startHour,
|
||||
endHour: widget.endHour,
|
||||
|
|
|
@ -10,13 +10,14 @@ class Table extends StatelessWidget {
|
|||
const Table({
|
||||
required this.startHour,
|
||||
required this.endHour,
|
||||
this.hoursOffset = 0,
|
||||
this.size,
|
||||
this.tableDirection = Axis.vertical,
|
||||
this.hourDimension = 80,
|
||||
this.tableOffset = 20,
|
||||
this.theme = const TableTheme(),
|
||||
Key? key,
|
||||
}) : super(key: key);
|
||||
super.key,
|
||||
});
|
||||
|
||||
/// The [Axis] in which the table is layed out.
|
||||
final Axis tableDirection;
|
||||
|
@ -30,6 +31,9 @@ class Table extends StatelessWidget {
|
|||
/// The hour the table ends at.
|
||||
final int endHour;
|
||||
|
||||
/// The time offset to increase all hour labels with
|
||||
final int hoursOffset;
|
||||
|
||||
/// The length in pixel of a single hour in the table.
|
||||
final double hourDimension;
|
||||
|
||||
|
@ -55,7 +59,7 @@ class Table extends StatelessWidget {
|
|||
Column(
|
||||
children: [
|
||||
Text(
|
||||
'${((i == 24) ? '00' : i.toString()).padLeft(2, '0')}'
|
||||
'${(((i + hoursOffset) == 24) ? '00' : ((i + hoursOffset) % 24).toString()).padLeft(2, '0')}'
|
||||
':00',
|
||||
style: theme.timeStyle ??
|
||||
Theme.of(context).textTheme.bodyLarge,
|
||||
|
@ -124,7 +128,7 @@ class Table extends StatelessWidget {
|
|||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'${i.toString().padLeft(2, '0')}:00',
|
||||
'${((i + hoursOffset) % 24).toString().padLeft(2, '0')}:00',
|
||||
style: theme.timeStyle ??
|
||||
Theme.of(context).textTheme.bodyLarge,
|
||||
),
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: flutter_timetable
|
||||
description: Flutter package to create a Timetable Widget that display blocks of widgets inside a timetable.
|
||||
version: 1.2.1
|
||||
version: 1.3.0
|
||||
repository: https://github.com/Iconica-Development/timetable
|
||||
|
||||
environment:
|
||||
|
|
Loading…
Reference in a new issue