Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: provider implementation, state manager, board params #12

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion example/ios/Flutter/AppFrameworkInfo.plist
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>11.0</string>
<string>12.0</string>
</dict>
</plist>
8 changes: 4 additions & 4 deletions example/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 1300;
LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
331C8080294A63A400263BE5 = {
Expand Down Expand Up @@ -344,7 +344,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down Expand Up @@ -471,7 +471,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -520,7 +520,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1300"
LastUpgradeVersion = "1510"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion example/ios/Runner/AppDelegate.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import UIKit
import Flutter

@UIApplicationMain
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
Expand Down
144 changes: 90 additions & 54 deletions example/lib/board_builder.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import 'dart:io';

import 'package:dotted_border/dotted_border.dart';
import 'package:flutter/material.dart';
import 'package:kanban_board/custom/board.dart';
import 'package:kanban_board/models/inputs.dart';
import 'package:kanban_board/kanban_board.dart';

import 'kanban_data.dart';
import 'widgets/board_header.dart';
import 'widgets/card.dart';
import 'widgets/group_card.dart';
import 'widgets/list_footer.dart';
import 'widgets/list_header.dart';

Expand All @@ -18,11 +18,33 @@ class BoardBuilder extends StatefulWidget {
}

class _BoardBuilderState extends State<BoardBuilder> {
get width =>
double get width =>
Platform.isWindows || Platform.isLinux || Platform.isMacOS ? 350 : 250;
final _controller = KanbanBoardController();

@override
Widget build(BuildContext context) {
final kanbanGroups = List.generate(
kanbanData.length,
(index) => KanbanBoardGroup(
id: kanbanData.keys.elementAt(index),
name: kanbanData.keys.elementAt(index),
items: (kanbanData.values.elementAt(index)['items'] as List)
.map<KanbanCardImpl>(
(e) => KanbanCardImpl(
itemId: index.toString(),
title: e['title'],
date: e['date'],
avatar: persons[
kanbanData.values.elementAt(index)['items'].indexOf(e) % 4],
completedTasks:
int.parse(e['tasks'].toString().split('/').first),
totalTasks: int.parse(e['tasks'].toString().split('/').last),
),
)
.toList(),
),
);
return Scaffold(
backgroundColor: const Color.fromRGBO(249, 244, 240, 1),
body: SafeArea(
Expand All @@ -36,60 +58,74 @@ class _BoardBuilderState extends State<BoardBuilder> {
),
Expanded(
child: KanbanBoard(
List.generate(kanbanData.length, (index) {
final element = kanbanData.values.elementAt(index);
return BoardListsData(
backgroundColor: const Color.fromRGBO(249, 244, 240, 1),
width: width,
footer: const ListFooter(),
headerBackgroundColor:
const Color.fromRGBO(249, 244, 240, 1),
header: ListHeader(
title: kanbanData.keys.elementAt(index),
stateColor: element['color'],
controller: _controller,
groupHeaderBuilder: (context, groupId) => ListHeader(
updateBoard: _updateBoard,
controller: _controller,
stateColor: kanbanData[groupId]!['color'],
title: groupId,
),
items: List.generate(element['items'].length, (index) {
int totalTasks = int.parse(element['items'][index]
['tasks']
.toString()
.split('/')
.last);
int completedTasks = int.parse(element['items'][index]
['tasks']
.toString()
.split('/')
.first);

return KanbanCard(
title: element['items'][index]['title'],
completedTasks: completedTasks,
totalTasks: totalTasks,
date: element['items'][index]['date'],
tasks: element['items'][index]['tasks'],
avatar: persons[index % 4],
);
}));
}),
onItemLongPress: (cardIndex, listIndex) {},
onItemReorder:
(oldCardIndex, newCardIndex, oldListIndex, newListIndex) {},
onListLongPress: (listIndex) {},
onListReorder: (oldListIndex, newListIndex) {},
onItemTap: (cardIndex, listIndex) {},
onListTap: (listIndex) {},
onListRename: (oldName, newName) {},
backgroundColor: const Color.fromRGBO(249, 244, 240, 1),
displacementY: 124,
displacementX: 100,
textStyle: const TextStyle(
fontSize: 18,
color: Colors.black,
fontWeight: FontWeight.w500),
),
),
groupFooterBuilder: (context, groupId) => const ListFooter(),
boardDecoration: const BoxDecoration(
color: Color.fromRGBO(249, 244, 240, 1),
),
groupDecoration: const BoxDecoration(
color: Color.fromRGBO(249, 244, 240, 1),
),
groupConstraints: BoxConstraints(
minWidth: width, maxWidth: width, minHeight: 300),
itemGhost: DottedBorder(
child: const Center(
child: Text(
"Drop your task here",
style:
TextStyle(fontSize: 18, fontWeight: FontWeight.bold),
)),
),
groups: kanbanGroups,
groupItemBuilder: (context, groupId, itemIndex) {
final groupItem = kanbanGroups
.firstWhere((element) => element.id == groupId)
.items
.elementAt(itemIndex);
return GroupCard(
title: groupItem.title,
completedTasks: groupItem.completedTasks,
totalTasks: groupItem.totalTasks,
date: groupItem.date,
tasks: groupItem.totalTasks.toString(),
avatar: persons[itemIndex % 4],
);
}),
)
],
),
),
);
}

void _updateBoard() {
setState(() {});
}
}

class KanbanCardImpl extends KanbanBoardGroupItem {
final String itemId;
final String title;
final String date;
final String avatar;
final int completedTasks;
final int totalTasks;

KanbanCardImpl({
required this.itemId,
required this.title,
required this.date,
required this.avatar,
required this.completedTasks,
required this.totalTasks,
});

@override
String get id => itemId;
}
127 changes: 118 additions & 9 deletions example/lib/kanban_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import 'package:flutter/material.dart';

Map<String, dynamic> kanbanData = {
'Blocked': {
'color': const Color.fromRGBO(239, 147, 148, 1),
'color': const Color.fromARGB(255, 0, 0, 0),
'items': [
{
'title': 'Making A New Trend In Poster',
'title': 'Creative Outdoor Ads',
'date': '17 Dec 2022',
'tasks': '30/48'
},
Expand Down Expand Up @@ -39,9 +39,48 @@ Map<String, dynamic> kanbanData = {
{
'title': 'Advertising Outdoors',
'date': '17 Dec 2022',
'tasks': '53/70'
'tasks': '53/70',
},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{'title': 'Create Remarkable', 'date': '17 Nov 2022', 'tasks': '15/56'},
{
'title': 'Manufacturing Equipment',
'date': '17 Dec 2022',
Expand Down Expand Up @@ -84,11 +123,81 @@ Map<String, dynamic> kanbanData = {
},
]
},
'Testing': {
'color': const Color.fromARGB(255, 235, 235, 148),
'items': [
{
'title': 'Creative Outdoor Ads',
'date': '23 Dec 2022',
'tasks': '20/20'
},
{
'title': 'Promotional Advertising Speciality',
'date': '17 Nov 2022',
'tasks': '15/15'
},
{
'title': 'Search Engine OPtimization',
'date': '22 Oct 2022',
'tasks': '67/67'
},
]
},
'Review': {
'color': const Color.fromARGB(255, 250, 234, 89),
'items': [
{
'title': 'Creative Outdoor Ads',
'date': '23 Dec 2022',
'tasks': '20/20'
},
{
'title': 'Promotional Advertising Speciality',
'date': '17 Nov 2022',
'tasks': '15/15'
},
{
'title': 'Search Engine OPtimization',
'date': '22 Oct 2022',
'tasks': '67/67'
},
]
},
'Cancelled': {
'color': const Color.fromARGB(255, 248, 41, 30),
'items': [
{
'title': 'Creative Outdoor Ads',
'date': '23 Dec 2022',
'tasks': '20/20'
},
]
},
'Production': {
'color': const Color.fromARGB(255, 0, 248, 58),
'items': [
{
'title': 'Creative Outdoor Ads',
'date': '23 Dec 2022',
'tasks': '20/20'
},
]
},
'Staging': {
'color': const Color.fromARGB(255, 8, 61, 232),
'items': [
{
'title': 'Creative Outdoor Ads',
'date': '23 Dec 2022',
'tasks': '20/20'
},
]
},
};

List<String> persons = [
'assets/person1.jpg',
'assets/person2.jpg',
'assets/person3.jpg',
'assets/person4.jpg',
];
List<String> persons = [
'assets/person1.jpg',
'assets/person2.jpg',
'assets/person3.jpg',
'assets/person4.jpg',
];
9 changes: 9 additions & 0 deletions example/lib/models/group_more_action.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
enum GroupMoreAction {
editTitle('Edit title'),
createNewTask('Create new task'),
deleteGroup('Delete group');

final String label;

const GroupMoreAction(this.label);
}
Loading