Created
October 20, 2020 14:42
-
-
Save gladimdim/3561bef84759b36f80ebe040bdddee9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: MyHomePage(title: 'Family planner'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
MyHomePage({Key key, this.title}) : super(key: key); | |
final String title; | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
// Here we take the value from the MyHomePage object that was created by | |
// the App.build method, and use it to set our appbar title. | |
title: Text(widget.title), | |
), | |
body: RootView(), | |
); | |
} | |
} | |
class RootView extends StatefulWidget { | |
final Dashboard board = Dashboard(); | |
@override | |
_RootViewState createState() => _RootViewState(); | |
} | |
class _RootViewState extends State<RootView> { | |
final ScrollController _horizontalScroll = ScrollController(); | |
double firstColumnleft = 0.0; | |
@override | |
Widget build(BuildContext context) { | |
var rowHeight = MediaQuery.of(context).size.height / 8; | |
return Stack( | |
children: [ | |
Container( | |
width: MediaQuery.of(context).size.width * 2, | |
height: MediaQuery.of(context).size.height * 2, | |
), | |
Positioned.fill( | |
left: 60, | |
top: 0, | |
child: SingleChildScrollView( | |
child: Column( | |
children: widget.board.days | |
.map( | |
(modelDay) => Container( | |
height: rowHeight, | |
child: ListView( | |
scrollDirection: Axis.horizontal, | |
children: modelDay.tasks | |
.map( | |
(task) => ConstrainedBox( | |
constraints: BoxConstraints( | |
maxHeight: rowHeight, | |
minWidth: 60, | |
), | |
child: Card( | |
child: Column( | |
children: [ | |
Text( | |
task.text, | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
), | |
), | |
Text(task.time.toString()), | |
], | |
), | |
), | |
), | |
) | |
.toList(), | |
), | |
), | |
) | |
.toList(), | |
), | |
), | |
), | |
Positioned( | |
top: 0, | |
left: firstColumnleft, | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
children: widget.board.days | |
.map( | |
(modelDay) => SizedBox( | |
width: 50, | |
height: rowHeight, | |
child: Card( | |
color: modelDay.titleColor, | |
child: Text( | |
modelDay.title, | |
), | |
), | |
), | |
) | |
.toList(), | |
), | |
), | |
], | |
); | |
} | |
} | |
class Dashboard { | |
List<DayModel> days = [ | |
DayModel( | |
title: "Mon", | |
titleColor: Colors.green, | |
), | |
DayModel( | |
title: "Tue", | |
titleColor: Colors.red, | |
), | |
DayModel( | |
title: "Wed", | |
titleColor: Colors.yellow, | |
), | |
DayModel( | |
title: "Thu", | |
titleColor: Colors.blue, | |
), | |
DayModel( | |
title: "Fri", | |
titleColor: Colors.green, | |
), | |
DayModel( | |
title: "Sat", | |
titleColor: Colors.amberAccent, | |
), | |
DayModel( | |
title: "Sun", | |
titleColor: Colors.limeAccent, | |
), | |
]; | |
} | |
class DayModel { | |
final String title; | |
final Color titleColor; | |
List<DayModelTask> tasks = [ | |
DayModelTask(text: "Данило плавання", time: DateTime.now()), | |
DayModelTask(text: "Данило Школа", time: DateTime.now()), | |
DayModelTask(text: "Данило Легко Легко Танці", time: DateTime.now()), | |
DayModelTask(text: "Данило ", time: DateTime.now()), | |
]; | |
DayModel({this.title, this.titleColor}); | |
} | |
class DayModelTask { | |
String text; | |
DateTime time; | |
DayModelTask({this.text, this.time}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment