From 0ed1847672bf26396b072a32eeecca75d38144fd Mon Sep 17 00:00:00 2001 From: Harinandan Date: Wed, 19 Jan 2022 10:29:02 +0530 Subject: [PATCH] Refactor Settings Menu Element into seperate file --- .../settings/widgets/settings_menu.dart | 46 +------------------ .../widgets/settings_menu_element.dart | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 45 deletions(-) create mode 100644 frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu_element.dart diff --git a/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu.dart b/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu.dart index 543f4fe9e0..22b049a4f5 100644 --- a/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu.dart +++ b/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu.dart @@ -1,3 +1,4 @@ +import 'package:app_flowy/workspace/presentation/settings/widgets/settings_menu_element.dart'; import 'package:flutter/material.dart'; class SettingsMenu extends StatelessWidget { @@ -35,48 +36,3 @@ class SettingsMenu extends StatelessWidget { ); } } - -class SettingsMenuElement extends StatelessWidget { - const SettingsMenuElement({ - Key? key, - required this.index, - required this.label, - required this.icon, - required this.changeSelectedIndex, - required this.currentIndex, - }) : super(key: key); - - final int index; - final int currentIndex; - final String label; - final IconData icon; - final Function changeSelectedIndex; - - @override - Widget build(BuildContext context) { - return ListTile( - leading: Icon( - icon, - size: 16, - color: Colors.black, - ), - onTap: () { - changeSelectedIndex(index); - }, - selected: index == currentIndex, - selectedColor: Colors.black, - selectedTileColor: Colors.blue.shade700, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(5), - ), - minLeadingWidth: 0, - title: Text( - label, - style: const TextStyle( - fontSize: 14, - fontWeight: FontWeight.w600, - ), - ), - ); - } -} diff --git a/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu_element.dart b/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu_element.dart new file mode 100644 index 0000000000..adfe45010e --- /dev/null +++ b/frontend/app_flowy/lib/workspace/presentation/settings/widgets/settings_menu_element.dart @@ -0,0 +1,46 @@ +import 'package:flutter/material.dart'; + +class SettingsMenuElement extends StatelessWidget { + const SettingsMenuElement({ + Key? key, + required this.index, + required this.label, + required this.icon, + required this.changeSelectedIndex, + required this.currentIndex, + }) : super(key: key); + + final int index; + final int currentIndex; + final String label; + final IconData icon; + final Function changeSelectedIndex; + + @override + Widget build(BuildContext context) { + return ListTile( + leading: Icon( + icon, + size: 16, + color: Colors.black, + ), + onTap: () { + changeSelectedIndex(index); + }, + selected: index == currentIndex, + selectedColor: Colors.black, + selectedTileColor: Colors.blue.shade700, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular(5), + ), + minLeadingWidth: 0, + title: Text( + label, + style: const TextStyle( + fontSize: 14, + fontWeight: FontWeight.w600, + ), + ), + ); + } +}