Skip to content

Instantly share code, notes, and snippets.

@radeksvarz
Last active February 17, 2020 01:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radeksvarz/0b3c89559eb4727f6db62fb87d0fd8c1 to your computer and use it in GitHub Desktop.
Save radeksvarz/0b3c89559eb4727f6db62fb87d0fd8c1 to your computer and use it in GitHub Desktop.
dartpad-rozvrh
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
// theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
appBar: AppBar(
title: Text("Rozvrh dne"),
actions: <Widget>[
RaisedButton(
onPressed: () {},
child: Text("Přidat"),
),
],
),
body: SafeArea(
child: ScheduleList(),
),
),
);
}
}
class ScheduleList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return ListView(
children: ListTile.divideTiles(
color: Colors.black,
context: context,
tiles: <Widget>[
ListTile(
leading: Icon(Icons.settings),
title: Text("Pro neurčený čas se uplatní režim"),
trailing: Chip(label: Text("Offline"))),
ListTile(
title: Text("Ve všední dny", style: TextStyle(fontSize: 24))),
SchedulePart(
title: "Po půlnoci",
screenTimeType: "Offline",
timeSpan: "00:00 - 06:00",
appliedDays: 0x7F,
icon: Icon(Icons.hotel)),
SchedulePart(
title: "Ráno",
screenTimeType: "Kreativní",
timeSpan: "06:00 - 07:45",
appliedDays: 0x1F,
icon: Icon(Icons.wb_sunny)),
SchedulePart(
title: "Škola",
screenTimeType: "Edu",
timeSpan: "07:45 - 14:30",
appliedDays: 0x0F,
icon: Icon(Icons.account_balance)),
SchedulePart(
title: "Škola - pátek",
screenTimeType: "Edu",
timeSpan: "07:45 - 12:30",
appliedDays: 0x10,
icon: Icon(Icons.account_balance)),
SchedulePart(
title: "Odpoledne / kroužky",
screenTimeType: "Konzum",
timeSpan: "14:30 - 18:30",
appliedDays: 0x1F,
icon: Icon(Icons.nature_people)),
SchedulePart(
title: "Večer",
screenTimeType: "Edu",
timeSpan: "18:30 - 20:00",
appliedDays: 0x1F,
icon: Icon(Icons.brightness_3)),
SchedulePart(
title: "Do půlnoci v týdnu",
screenTimeType: "Offline",
timeSpan: "20:00 - 24:00",
appliedDays: 0x4F,
icon: Icon(Icons.hotel)),
ListTile(title: Text("O víkendu", style: TextStyle(fontSize: 24))),
SchedulePart(
title: "Po půlnoci",
screenTimeType: "Offline",
timeSpan: "00:00 - 06:00",
appliedDays: 0x60,
icon: Icon(Icons.hotel)),
SchedulePart(
title: "Přes den o víkendu",
screenTimeType: "Konzum",
timeSpan: "06:00 - 21:00",
appliedDays: 0x60,
icon: Icon(Icons.wb_sunny)),
SchedulePart(
title: "Do půlnoci víkend",
screenTimeType: "Offline",
timeSpan: "21:00 - 24:00",
appliedDays: 0x30,
icon: Icon(Icons.hotel)),
]).toList(),
);
}
}
class SchedulePart extends StatelessWidget {
final String title;
final String timeSpan;
final String screenTimeType;
final Icon icon;
final int appliedDays;
SchedulePart(
{Key key,
this.title,
this.icon,
this.timeSpan,
this.appliedDays,
this.screenTimeType})
: super(key: key);
@override
Widget build(BuildContext context) {
return ListTile(
leading: icon,
title: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(title),
Chip(label: Text(screenTimeType)),
],
),
subtitle: Row(
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
Text(timeSpan),
AppliedDays(appliedDays),
],
),
trailing: Icon(Icons.keyboard_arrow_right),
onTap: () {},
);
}
}
class AppliedDays extends StatelessWidget {
/// bitmap of selected days ... bits 1 (Monday) to 7 (Sunday)
final int daysMap;
AppliedDays(this.daysMap) : super();
@override
Widget build(BuildContext context) {
return Row(
children: List<Widget>.generate(7, (int index) {
var _dayIsSelected = daysMap & [1, 2, 4, 8, 16, 32, 64][index] > 0;
return Padding(
padding: const EdgeInsets.symmetric(horizontal: 2.0),
child: Text(
["Po", "Út", "St", "Čt", "Pá", "So", "Ne"][index],
style: TextStyle(
color: _dayIsSelected ? null : Colors.grey[300],
decoration: _dayIsSelected ? TextDecoration.underline : null,
decorationStyle: TextDecorationStyle.solid),
),
);
}));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment