Skip to content
Open
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
143 changes: 45 additions & 98 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'package:flutter/cupertino.dart';
import 'package:time_range_picker/time_range_picker.dart';
import 'package:flutter/material.dart';
import 'package:time_range_picker/time_range_picker.dart';

void main() {
runApp(MyApp());
Expand Down Expand Up @@ -93,24 +93,14 @@ class _MyHomePageState extends State<MyHomePage> {
ticks: 12,
ticksColor: Colors.white,
snap: true,
labels: [
"12 am",
"3 am",
"6 am",
"9 am",
"12 pm",
"3 pm",
"6 pm",
"9 pm"
].asMap().entries.map((e) {
return ClockLabel.fromIndex(
idx: e.key, length: 8, text: e.value);
labels: ["12 am", "3 am", "6 am", "9 am", "12 pm", "3 pm", "6 pm", "9 pm"]
.asMap()
.entries
.map((e) {
return ClockLabel.fromIndex(idx: e.key, length: 8, text: e.value);
}).toList(),
labelOffset: -30,
labelStyle: TextStyle(
fontSize: 22,
color: Colors.grey,
fontWeight: FontWeight.bold),
labelStyle: TextStyle(fontSize: 22, color: Colors.grey, fontWeight: FontWeight.bold),
timeTextStyle: TextStyle(
color: Colors.orange[700],
fontSize: 24,
Expand Down Expand Up @@ -140,18 +130,11 @@ class _MyHomePageState extends State<MyHomePage> {
ticksOffset: -7,
ticksLength: 15,
ticksColor: Colors.grey,
labels: [
"12 am",
"3 am",
"6 am",
"9 am",
"12 pm",
"3 pm",
"6 pm",
"9 pm"
].asMap().entries.map((e) {
return ClockLabel.fromIndex(
idx: e.key, length: 8, text: e.value);
labels: ["12 am", "3 am", "6 am", "9 am", "12 pm", "3 pm", "6 pm", "9 pm"]
.asMap()
.entries
.map((e) {
return ClockLabel.fromIndex(idx: e.key, length: 8, text: e.value);
}).toList(),
labelOffset: 35,
rotateLabels: false,
Expand All @@ -168,10 +151,8 @@ class _MyHomePageState extends State<MyHomePage> {
paintingStyle: PaintingStyle.fill,
backgroundColor: Colors.grey.withOpacity(0.2),
labels: [
ClockLabel.fromTime(
time: TimeOfDay(hour: 7, minute: 0), text: "Start Work"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 18, minute: 0), text: "Go Home")
ClockLabel.fromTime(time: TimeOfDay(hour: 7, minute: 0), text: "Start Work"),
ClockLabel.fromTime(time: TimeOfDay(hour: 18, minute: 0), text: "Go Home")
],
start: TimeOfDay(hour: 10, minute: 0),
end: TimeOfDay(hour: 13, minute: 0),
Expand Down Expand Up @@ -205,21 +186,13 @@ class _MyHomePageState extends State<MyHomePage> {
width: 200,
),
labels: [
ClockLabel.fromTime(
time: TimeOfDay(hour: 6, minute: 0), text: "Get up"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 9, minute: 0), text: "Coffee time"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 15, minute: 0), text: "Afternoon"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 18, minute: 0),
text: "Time for a beer"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 22, minute: 0), text: "Go to Sleep"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 2, minute: 0), text: "Go for a pee"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 12, minute: 0), text: "Lunchtime!")
ClockLabel.fromTime(time: TimeOfDay(hour: 6, minute: 0), text: "Get up"),
ClockLabel.fromTime(time: TimeOfDay(hour: 9, minute: 0), text: "Coffee time"),
ClockLabel.fromTime(time: TimeOfDay(hour: 15, minute: 0), text: "Afternoon"),
ClockLabel.fromTime(time: TimeOfDay(hour: 18, minute: 0), text: "Time for a beer"),
ClockLabel.fromTime(time: TimeOfDay(hour: 22, minute: 0), text: "Go to Sleep"),
ClockLabel.fromTime(time: TimeOfDay(hour: 2, minute: 0), text: "Go for a pee"),
ClockLabel.fromTime(time: TimeOfDay(hour: 12, minute: 0), text: "Lunchtime!")
],
ticksColor: Colors.black,
labelOffset: 40,
Expand All @@ -242,18 +215,11 @@ class _MyHomePageState extends State<MyHomePage> {
handlerRadius: 8,
ticksColor: Colors.grey,
rotateLabels: false,
labels: [
"24 h",
"3 h",
"6 h",
"9 h",
"12 h",
"15 h",
"18 h",
"21 h"
].asMap().entries.map((e) {
return ClockLabel.fromIndex(
idx: e.key, length: 8, text: e.value);
labels: ["24 h", "3 h", "6 h", "9 h", "12 h", "15 h", "18 h", "21 h"]
.asMap()
.entries
.map((e) {
return ClockLabel.fromIndex(idx: e.key, length: 8, text: e.value);
}).toList(),
labelOffset: 30,
padding: 55,
Expand All @@ -278,18 +244,11 @@ class _MyHomePageState extends State<MyHomePage> {
ticks: 12,
ticksColor: Colors.grey,
ticksOffset: -12,
labels: [
"24 h",
"3 h",
"6 h",
"9 h",
"12 h",
"15 h",
"18 h",
"21 h"
].asMap().entries.map((e) {
return ClockLabel.fromIndex(
idx: e.key, length: 8, text: e.value);
labels: ["24 h", "3 h", "6 h", "9 h", "12 h", "15 h", "18 h", "21 h"]
.asMap()
.entries
.map((e) {
return ClockLabel.fromIndex(idx: e.key, length: 8, text: e.value);
}).toList(),
labelOffset: -30,
padding: 55,
Expand All @@ -314,18 +273,11 @@ class _MyHomePageState extends State<MyHomePage> {
ticks: 12,
ticksColor: Colors.grey,
ticksOffset: -12,
labels: [
"24 h",
"3 h",
"6 h",
"9 h",
"12 h",
"15 h",
"18 h",
"21 h"
].asMap().entries.map((e) {
return ClockLabel.fromIndex(
idx: e.key, length: 8, text: e.value);
labels: ["24 h", "3 h", "6 h", "9 h", "12 h", "15 h", "18 h", "21 h"]
.asMap()
.entries
.map((e) {
return ClockLabel.fromIndex(idx: e.key, length: 8, text: e.value);
}).toList(),
labelOffset: -30,
padding: 55,
Expand All @@ -344,8 +296,8 @@ class _MyHomePageState extends State<MyHomePage> {
),
ElevatedButton(
onPressed: () async {
TimeRange? result = await showTimeRangePicker(
context: context, barrierDismissible: false);
TimeRange? result =
await showTimeRangePicker(context: context, barrierDismissible: false);

print("result " + result.toString());
},
Expand All @@ -354,7 +306,7 @@ class _MyHomePageState extends State<MyHomePage> {
Divider(),
Text(
'As a regular widget:',
style: Theme.of(context).textTheme.headline6,
style: Theme.of(context).textTheme.headlineMedium,
textAlign: TextAlign.center,
),
Container(
Expand All @@ -366,10 +318,8 @@ class _MyHomePageState extends State<MyHomePage> {
paintingStyle: PaintingStyle.fill,
backgroundColor: Colors.grey.withOpacity(0.2),
labels: [
ClockLabel.fromTime(
time: TimeOfDay(hour: 7, minute: 0), text: "Start Work"),
ClockLabel.fromTime(
time: TimeOfDay(hour: 18, minute: 0), text: "Go Home")
ClockLabel.fromTime(time: TimeOfDay(hour: 7, minute: 0), text: "Start Work"),
ClockLabel.fromTime(time: TimeOfDay(hour: 18, minute: 0), text: "Go Home")
],
start: TimeOfDay(hour: 10, minute: 0),
end: TimeOfDay(hour: 13, minute: 0),
Expand All @@ -379,8 +329,7 @@ class _MyHomePageState extends State<MyHomePage> {
labelOffset: 15,
padding: 60,
disabledTime: TimeRange(
startTime: TimeOfDay(hour: 18, minute: 0),
endTime: TimeOfDay(hour: 7, minute: 0)),
startTime: TimeOfDay(hour: 18, minute: 0), endTime: TimeOfDay(hour: 7, minute: 0)),
disabledColor: Colors.red.withOpacity(0.5),
),
),
Expand Down Expand Up @@ -420,8 +369,8 @@ class _MyHomePageState extends State<MyHomePage> {
TextButton(
child: Text('My custom ok'),
onPressed: () {
Navigator.of(context).pop(TimeRange(
startTime: _startTime, endTime: _endTime));
Navigator.of(context)
.pop(TimeRange(startTime: _startTime, endTime: _endTime));
},
),
],
Expand Down Expand Up @@ -454,9 +403,7 @@ class _MyHomePageState extends State<MyHomePage> {
strokeWidth: 4,
ticks: 12,
activeTimeTextStyle: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 22,
color: Colors.white),
fontWeight: FontWeight.normal, fontSize: 22, color: Colors.white),
timeTextStyle: TextStyle(
fontWeight: FontWeight.normal,
fontSize: 22,
Expand Down
9 changes: 8 additions & 1 deletion example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand Down Expand Up @@ -134,7 +141,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.7"
version: "0.4.8"
time_range_picker:
dependency: "direct main"
description:
Expand Down
2 changes: 1 addition & 1 deletion example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import 'package:example/main.dart';
import '../lib/main.dart';

void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
Expand Down
Loading