Merge pull request #7 from Iconica-Development/1.1.0

1.1.0
This commit is contained in:
Gorter-dev 2023-08-17 14:05:39 +02:00 committed by GitHub
commit 7b80839bea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 128 additions and 138 deletions

View file

@ -1,32 +1,12 @@
name: CI name: Iconica Standard Component CI Workflow
# Workflow Caller version: 1.0.0
on: on:
push:
branches: [ master ]
pull_request: pull_request:
branches: workflow_dispatch:
- master
- feature/*
- bugfix/*
- hotfix/*
jobs: jobs:
lint: call-global-iconica-workflow:
runs-on: ubuntu-latest uses: Iconica-Development/.github/.github/workflows/component-ci.yml@master
steps: secrets: inherit
- uses: actions/checkout@v3 permissions: write-all
- uses: actions/cache@v3
with:
path: |
~/.gradle/wrapper
/opt/hostedtoolcache/flutter
key: ${{ runner.OS }}-flutter-install-cache
- uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Flutter pub get
run: flutter pub get
- name: Flutter format
run: flutter format -o none --set-exit-if-changed .
- name: Flutter analyze
run: flutter analyze

1
.gitignore vendored
View file

@ -28,6 +28,7 @@ migrate_working_dir/
.dart_tool/ .dart_tool/
.packages .packages
build/ build/
.metadata
example/android/ example/android/
example/ios/ example/ios/

View file

@ -1,10 +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: f1875d570e39de09040c8f79aa13cc56baab8db1
channel: stable
project_type: package

View file

@ -10,3 +10,7 @@
* Added horizontal variant * Added horizontal variant
* Adjustable size for the component * Adjustable size for the component
## [1.1.0] - 17 August 2023
* Set scrolling to the current time by default if there are no blocks

View file

@ -1,11 +1,11 @@
# This file tracks properties of this Flutter project. # This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc. # Used by Flutter tool to assess capabilities and perform upgrades etc.
# #
# This file should be version controlled. # This file should be version controlled and should not be manually edited.
version: version:
revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 revision: "efbf63d9c66b9f6ec30e9ad4611189aa80003d31"
channel: stable channel: "stable"
project_type: app project_type: app
@ -13,11 +13,11 @@ project_type: app
migration: migration:
platforms: platforms:
- platform: root - platform: root
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
- platform: ios - platform: web
create_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 create_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
base_revision: 52b3dc25f6471c27b2144594abb11c741cb88f57 base_revision: efbf63d9c66b9f6ec30e9ad4611189aa80003d31
# User provided section # User provided section

View file

@ -3,7 +3,7 @@
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:timetable/timetable.dart'; import 'package:flutter_timetable/timetable.dart';
void main() { void main() {
runApp(const MaterialApp(home: TimetableDemo())); runApp(const MaterialApp(home: TimetableDemo()));
@ -27,8 +27,8 @@ class _TimetableDemoState extends State<TimetableDemo> {
child: Container( child: Container(
color: Colors.red, color: Colors.red,
child: const Padding( child: const Padding(
padding: const EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: const Text( child: Text(
'Exercise', 'Exercise',
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),
@ -42,8 +42,8 @@ class _TimetableDemoState extends State<TimetableDemo> {
child: Container( child: Container(
color: Colors.orange, color: Colors.orange,
child: const Padding( child: const Padding(
padding: const EdgeInsets.all(8.0), padding: EdgeInsets.all(8.0),
child: const Text( child: Text(
'Brunch', 'Brunch',
style: TextStyle(color: Colors.white), style: TextStyle(color: Colors.white),
), ),

View file

@ -5,10 +5,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: async name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0 sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.10.0" version: "2.11.0"
boolean_selector: boolean_selector:
dependency: transitive dependency: transitive
description: description:
@ -21,10 +21,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: characters name: characters
sha256: e6a326c8af69605aec75ed6c187d06b349707a27fbff8222ca9cc2cff167975c sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.2.1" version: "1.3.0"
clock: clock:
dependency: transitive dependency: transitive
description: description:
@ -37,10 +37,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: collection name: collection
sha256: cfc915e6923fe5ce6e153b0723c753045de46de1b4d63771530504004a45fae0 sha256: f092b211a4319e98e5ff58223576de6c2803db36221657b46c82574721240687
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.17.0" version: "1.17.2"
cupertino_icons: cupertino_icons:
dependency: "direct main" dependency: "direct main"
description: description:
@ -66,63 +66,62 @@ packages:
dependency: "direct dev" dependency: "direct dev"
description: description:
name: flutter_lints name: flutter_lints
sha256: aeb0b80a8b3709709c9cc496cdc027c5b3216796bc0af0ce1007eaf24464fd4c sha256: "2118df84ef0c3ca93f96123a616ae8540879991b8b57af2f81b76a7ada49b2a4"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.1" version: "2.0.2"
flutter_test: flutter_test:
dependency: "direct dev" dependency: "direct dev"
description: flutter description: flutter
source: sdk source: sdk
version: "0.0.0" version: "0.0.0"
js: flutter_timetable:
dependency: transitive dependency: "direct main"
description: description:
name: js path: ".."
sha256: "5528c2f391ededb7775ec1daa69e65a2d61276f7552de2b5f7b8d34ee9fd4ab7" relative: true
url: "https://pub.dev" source: path
source: hosted version: "1.1.0"
version: "0.6.5"
lints: lints:
dependency: transitive dependency: transitive
description: description:
name: lints name: lints
sha256: "5cfd6509652ff5e7fe149b6df4859e687fca9048437857cb2e65c8d780f396e3" sha256: "0a217c6c989d21039f1498c3ed9f3ed71b354e69873f13a8dfc3c9fe76f1b452"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.0.0" version: "2.1.1"
matcher: matcher:
dependency: transitive dependency: transitive
description: description:
name: matcher name: matcher
sha256: "16db949ceee371e9b99d22f88fa3a73c4e59fd0afed0bd25fc336eb76c198b72" sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.12.13" version: "0.12.16"
material_color_utilities: material_color_utilities:
dependency: transitive dependency: transitive
description: description:
name: material_color_utilities name: material_color_utilities
sha256: d92141dc6fe1dad30722f9aa826c7fbc896d021d792f80678280601aff8cf724 sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.2.0" version: "0.5.0"
meta: meta:
dependency: transitive dependency: transitive
description: description:
name: meta name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42" sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.0" version: "1.9.1"
path: path:
dependency: transitive dependency: transitive
description: description:
name: path name: path
sha256: db9d4f58c908a4ba5953fcee2ae317c94889433e5024c27ce74a37f94267945b sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.8.2" version: "1.8.3"
sky_engine: sky_engine:
dependency: transitive dependency: transitive
description: flutter description: flutter
@ -132,10 +131,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: source_span name: source_span
sha256: dd904f795d4b4f3b870833847c461801f6750a9fa8e61ea5ac53f9422b31f250 sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "1.9.1" version: "1.10.0"
stack_trace: stack_trace:
dependency: transitive dependency: transitive
description: description:
@ -172,17 +171,10 @@ packages:
dependency: transitive dependency: transitive
description: description:
name: test_api name: test_api
sha256: ad540f65f92caa91bf21dfc8ffb8c589d6e4dc0c2267818b4cc2792857706206 sha256: "75760ffd7786fffdfb9597c35c5b27eaeec82be8edfb6d71d32651128ed7aab8"
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "0.4.16" version: "0.6.0"
timetable:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "1.0.0"
vector_math: vector_math:
dependency: transitive dependency: transitive
description: description:
@ -191,6 +183,14 @@ packages:
url: "https://pub.dev" url: "https://pub.dev"
source: hosted source: hosted
version: "2.1.4" version: "2.1.4"
web:
dependency: transitive
description:
name: web
sha256: dc8ccd225a2005c1be616fe02951e2e342092edf968cf0844220383757ef8f10
url: "https://pub.dev"
source: hosted
version: "0.1.4-beta"
sdks: sdks:
dart: ">=2.18.0 <3.0.0" dart: ">=3.1.0-185.0.dev <4.0.0"
flutter: ">=1.17.0" flutter: ">=1.17.0"

View file

@ -3,17 +3,17 @@ description: Timetable Widget
publish_to: 'none' publish_to: 'none'
version: 1.0.0+1 version: 1.1.0+2
environment: environment:
sdk: ">=2.17.6 <3.0.0" sdk: ">=3.0.0 <4.0.0"
dependencies: dependencies:
flutter: flutter:
sdk: flutter sdk: flutter
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
timetable: flutter_timetable:
path: ../ path: ../
dev_dependencies: dev_dependencies:

View file

@ -3,7 +3,7 @@
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:timetable/src/models/time_block.dart'; import 'package:flutter_timetable/src/models/time_block.dart';
/// Combine blocks that have the same id and the same time. /// Combine blocks that have the same id and the same time.
List<TimeBlock> combineBlocksWithId(List<TimeBlock> blocks) { List<TimeBlock> combineBlocksWithId(List<TimeBlock> blocks) {

View file

@ -6,11 +6,11 @@ import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/scheduler.dart'; import 'package:flutter/scheduler.dart';
import 'package:timetable/src/block_service.dart'; import 'package:flutter_timetable/src/block_service.dart';
import 'package:timetable/src/models/table_theme.dart'; import 'package:flutter_timetable/src/models/table_theme.dart';
import 'package:timetable/src/models/time_block.dart'; import 'package:flutter_timetable/src/models/time_block.dart';
import 'package:timetable/src/widgets/block.dart'; import 'package:flutter_timetable/src/widgets/block.dart';
import 'package:timetable/src/widgets/table.dart' as table; import 'package:flutter_timetable/src/widgets/table.dart' as table;
class Timetable extends StatefulWidget { class Timetable extends StatefulWidget {
/// [Timetable] widget that displays a timetable with [TimeBlock]s. /// [Timetable] widget that displays a timetable with [TimeBlock]s.
@ -22,6 +22,7 @@ class Timetable extends StatefulWidget {
this.tableDirection = Axis.vertical, this.tableDirection = Axis.vertical,
this.timeBlocks = const [], this.timeBlocks = const [],
this.size, this.size,
this.initialScrollTime,
this.scrollController, this.scrollController,
this.scrollPhysics, this.scrollPhysics,
this.startHour = 0, this.startHour = 0,
@ -63,6 +64,9 @@ class Timetable extends StatefulWidget {
/// The theme of the timetable. /// The theme of the timetable.
final TableTheme theme; final TableTheme theme;
/// The initial time to scroll to if there are no timeblocks. If nothing is provided it will scroll to the current time or to the first block if there is one.
final TimeOfDay? initialScrollTime;
/// The scroll controller to control the scrolling of the timetable. /// The scroll controller to control the scrolling of the timetable.
final ScrollController? scrollController; final ScrollController? scrollController;
@ -90,6 +94,8 @@ class _TimetableState extends State<Timetable> {
widget.scrollController ?? ScrollController(initialScrollOffset: 0); widget.scrollController ?? ScrollController(initialScrollOffset: 0);
if (widget.timeBlocks.isNotEmpty) { if (widget.timeBlocks.isNotEmpty) {
_scrollToFirstBlock(); _scrollToFirstBlock();
} else {
_scrollToInitialTime();
} }
} }
@ -224,32 +230,28 @@ class _TimetableState extends State<Timetable> {
); );
} }
Size _calculateTableStart(Axis axis) { Size _calculateTableStart(Axis axis) => Size(
return Size( (axis == Axis.horizontal)
(axis == Axis.horizontal) ? _calculateTableTextSize().width / 2
? _calculateTableTextSize().width / 2 : _calculateTableTextSize().width +
: _calculateTableTextSize().width + widget.theme.tablePaddingStart +
widget.theme.tablePaddingStart + widget.theme.tableTextOffset,
widget.theme.tableTextOffset, (axis == Axis.vertical)
(axis == Axis.vertical) ? _calculateTableTextSize().height / 2
? _calculateTableTextSize().height / 2 : _calculateTableTextSize().height,
: _calculateTableTextSize().height, );
);
}
Widget _showBlock(TimeBlock block, {double linePadding = 0}) { Widget _showBlock(TimeBlock block, {double linePadding = 0}) => Block(
return Block( blockDirection: widget.tableDirection,
blockDirection: widget.tableDirection, linePadding: linePadding,
linePadding: linePadding, start: block.start,
start: block.start, end: block.end,
end: block.end, startHour: widget.startHour,
startHour: widget.startHour, hourDimension: widget.hourDimension,
hourDimension: widget.hourDimension, blockDimension: widget.blockDimension,
blockDimension: widget.blockDimension, blockColor: widget.blockColor,
blockColor: widget.blockColor, child: block.child,
child: block.child, );
);
}
void _scrollToFirstBlock() { void _scrollToFirstBlock() {
SchedulerBinding.instance.addPostFrameCallback((_) { SchedulerBinding.instance.addPostFrameCallback((_) {
@ -271,19 +273,32 @@ class _TimetableState extends State<Timetable> {
}); });
} }
Size _calculateTableTextSize() { void _scrollToInitialTime() {
return (TextPainter( SchedulerBinding.instance.addPostFrameCallback((_) {
text: TextSpan( var startingTime = widget.initialScrollTime ?? TimeOfDay.now();
text: '22:22', var initialOffset =
style: widget.theme.timeStyle ?? Theme.of(context).textTheme.bodyLarge, (widget.hourDimension * (widget.endHour - widget.startHour)) *
), ((startingTime.hour - widget.startHour) /
maxLines: 1, (widget.endHour - widget.startHour)) +
textScaleFactor: MediaQuery.of(context).textScaleFactor, _calculateTableTextSize().width / 2;
textDirection: TextDirection.ltr, _scrollController.jumpTo(
)..layout()) initialOffset,
.size; );
});
} }
Size _calculateTableTextSize() => (TextPainter(
text: TextSpan(
text: '22:22',
style:
widget.theme.timeStyle ?? Theme.of(context).textTheme.bodyLarge,
),
maxLines: 1,
textScaleFactor: MediaQuery.of(context).textScaleFactor,
textDirection: TextDirection.ltr,
)..layout())
.size;
double calculateTableHeight() { double calculateTableHeight() {
var sum = 0.0; var sum = 0.0;
if (widget.mergeBlocks || widget.combineBlocks) { if (widget.mergeBlocks || widget.combineBlocks) {

View file

@ -3,7 +3,7 @@
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:timetable/src/models/table_theme.dart'; import 'package:flutter_timetable/src/models/table_theme.dart';
class Table extends StatelessWidget { class Table extends StatelessWidget {
/// The [Table] to draw an overview of timerange with corresponding hour lines /// The [Table] to draw an overview of timerange with corresponding hour lines

View file

@ -1,10 +1,10 @@
name: timetable name: flutter_timetable
description: Flutter package to create a Timetable Widget that display blocks of widgets inside a timetable. description: Flutter package to create a Timetable Widget that display blocks of widgets inside a timetable.
version: 1.0.0 version: 1.1.0
repository: https://github.com/Iconica-Development/timetable repository: https://github.com/Iconica-Development/timetable
environment: environment:
sdk: ">=2.18.0 <3.0.0" sdk: ">=3.0.0 <4.0.0"
flutter: ">=1.17.0" flutter: ">=1.17.0"
dependencies: dependencies:

View file

@ -4,8 +4,8 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
import 'package:timetable/src/block_service.dart'; import 'package:flutter_timetable/src/block_service.dart';
import 'package:timetable/timetable.dart'; import 'package:flutter_timetable/timetable.dart';
void main() { void main() {
group('test combineBlocksWithId', () { group('test combineBlocksWithId', () {