mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
Added login screen and Tree page screen to test graph view package
This commit is contained in:
33
lib/pages/home/bloc/home_bloc.dart
Normal file
33
lib/pages/home/bloc/home_bloc.dart
Normal file
@ -0,0 +1,33 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:graphview/GraphView.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_event.dart';
|
||||
import 'package:syncrow_web/pages/home/bloc/home_state.dart';
|
||||
|
||||
class HomeBloc extends Bloc<HomeEvent, HomeState> {
|
||||
final Graph graph = Graph()..isTree = true;
|
||||
final BuchheimWalkerConfiguration builder = BuchheimWalkerConfiguration();
|
||||
List<Node> sourcesList = [];
|
||||
List<Node> destinationsList = [];
|
||||
|
||||
HomeBloc() : super((HomeInitial())) {
|
||||
on<CreateNewNode>(_createNode);
|
||||
}
|
||||
|
||||
void _createNode(CreateNewNode event, Emitter<HomeState> emit) async {
|
||||
emit(HomeInitial());
|
||||
sourcesList.add(event.sourceNode);
|
||||
destinationsList.add(event.destinationNode);
|
||||
|
||||
for (int i = 0; i < sourcesList.length; i++) {
|
||||
graph.addEdge(sourcesList[i], destinationsList[i]);
|
||||
}
|
||||
|
||||
builder
|
||||
..siblingSeparation = (100)
|
||||
..levelSeparation = (150)
|
||||
..subtreeSeparation = (150)
|
||||
..orientation = (BuchheimWalkerConfiguration.ORIENTATION_TOP_BOTTOM);
|
||||
|
||||
emit(HomeUpdateTree(graph: graph, builder: builder));
|
||||
}
|
||||
}
|
19
lib/pages/home/bloc/home_event.dart
Normal file
19
lib/pages/home/bloc/home_event.dart
Normal file
@ -0,0 +1,19 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:graphview/GraphView.dart';
|
||||
|
||||
abstract class HomeEvent extends Equatable {
|
||||
const HomeEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class CreateNewNode extends HomeEvent {
|
||||
final Node sourceNode;
|
||||
final Node destinationNode;
|
||||
const CreateNewNode(
|
||||
{required this.sourceNode, required this.destinationNode});
|
||||
|
||||
@override
|
||||
List<Object> get props => [sourceNode, destinationNode];
|
||||
}
|
26
lib/pages/home/bloc/home_state.dart
Normal file
26
lib/pages/home/bloc/home_state.dart
Normal file
@ -0,0 +1,26 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:graphview/GraphView.dart';
|
||||
|
||||
abstract class HomeState extends Equatable {
|
||||
const HomeState();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class HomeInitial extends HomeState {}
|
||||
|
||||
class HomeCounterState extends HomeState {
|
||||
final int counter;
|
||||
const HomeCounterState(this.counter);
|
||||
}
|
||||
|
||||
class HomeUpdateTree extends HomeState {
|
||||
final Graph graph;
|
||||
final BuchheimWalkerConfiguration builder;
|
||||
|
||||
const HomeUpdateTree({required this.graph, required this.builder});
|
||||
|
||||
@override
|
||||
List<Object> get props => [graph, builder];
|
||||
}
|
Reference in New Issue
Block a user