-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
646 fe home page advanced nodes (#677)
* New provider for getting nodes by type * Create node options menu buttons * Add buttons to home page
- Loading branch information
1 parent
b429957
commit 738808d
Showing
5 changed files
with
198 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
64 changes: 64 additions & 0 deletions
64
.../FrontEnd/collaborative_science_platform/lib/screens/home_page/widgets/select_button.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import 'package:flutter/material.dart'; | ||
|
||
class SelectButton extends StatefulWidget { | ||
final int index; | ||
final String name; | ||
final bool selected; | ||
final Function onPressed; | ||
const SelectButton( | ||
{required this.index, | ||
required this.name, | ||
required this.selected, | ||
required this.onPressed, | ||
super.key}); | ||
|
||
@override | ||
State<SelectButton> createState() => _SelectButtonState(); | ||
} | ||
|
||
class _SelectButtonState extends State<SelectButton> { | ||
bool isHovering = false; | ||
@override | ||
Widget build(BuildContext context) { | ||
return MouseRegion( | ||
cursor: SystemMouseCursors.click, | ||
onEnter: (event) => setState(() => isHovering = true), | ||
onExit: (event) => setState(() => isHovering = false), | ||
child: GestureDetector( | ||
onTap: () { | ||
widget.onPressed(widget.index); | ||
}, | ||
child: Container( | ||
height: 35, | ||
width: 90, | ||
decoration: BoxDecoration( | ||
borderRadius: BorderRadius.circular(6), | ||
color: widget.selected | ||
? Colors.indigo[600] | ||
: isHovering | ||
? Colors.indigo[200] | ||
: Colors.grey[200], | ||
), | ||
padding: const EdgeInsets.all(10), | ||
margin: const EdgeInsets.only(right: 8), | ||
child: Row( | ||
mainAxisSize: MainAxisSize.min, | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
SelectionContainer.disabled( | ||
child: Text( | ||
widget.name, | ||
textAlign: TextAlign.center, | ||
style: TextStyle( | ||
fontSize: 12, | ||
fontWeight: FontWeight.w600, | ||
color: widget.selected ? Colors.white : Colors.grey[700]), | ||
), | ||
), | ||
], | ||
), | ||
), | ||
), | ||
); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...FrontEnd/collaborative_science_platform/lib/screens/home_page/widgets/select_buttons.dart
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import 'package:collaborative_science_platform/screens/home_page/widgets/select_button.dart'; | ||
import 'package:flutter/material.dart'; | ||
|
||
class SelectButtons extends StatefulWidget { | ||
final Function onTypeChange; | ||
const SelectButtons(this.onTypeChange, {super.key}); | ||
|
||
@override | ||
State<SelectButtons> createState() => _SelectButtonsState(); | ||
} | ||
|
||
class _SelectButtonsState extends State<SelectButtons> { | ||
int selectedIndex = 0; | ||
|
||
void selectOne(int index) async { | ||
setState(() { | ||
selectedIndex = index; | ||
}); | ||
widget.onTypeChange(index); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Row( | ||
mainAxisAlignment: MainAxisAlignment.center, | ||
children: [ | ||
SelectButton( | ||
index: 0, name: "Trending", selected: selectedIndex == 0, onPressed: selectOne), | ||
const SizedBox(width: 10.0), | ||
SelectButton(index: 1, name: "Latest", selected: selectedIndex == 1, onPressed: selectOne), | ||
const SizedBox(width: 10.0), | ||
SelectButton( | ||
index: 2, name: "Most Read", selected: selectedIndex == 2, onPressed: selectOne), | ||
const SizedBox(width: 10.0), | ||
SelectButton(index: 3, name: "Random", selected: selectedIndex == 3, onPressed: selectOne), | ||
// if (Provider.of<Auth>(context).isSignedIn) | ||
// Row( | ||
// children: [ | ||
// const SizedBox(width: 10.0), | ||
// SelectButton( | ||
// index: 4, name: "For You", selected: selectedIndex == 4, onPressed: selectOne), | ||
// ], | ||
// ), | ||
], | ||
); | ||
} | ||
} |