SankethBK / diaryvault

A personal diary application written in Flutter
https://play.google.com/store/apps/details?id=me.sankethbk.dairyapp
MIT License
91 stars 58 forks source link

Refactor settings page #39

Closed SankethBK closed 11 months ago

SankethBK commented 11 months ago

Settings page is getting cluttered with lot of options.

Instead of displaying all options linearly, we can group bunch of related options into an accordion.

For now we can group these options Change password, Change Email and Enable Fingerprint login into Security Settings

Initially Security settings will be shown

On clicking it will expand to show all 3 options

Screenshots are just for reference. Feel free to use accordion package or implement your own widget

sameer1612 commented 11 months ago

I can take it, do assign if up for grabs. Thanks!

SankethBK commented 11 months ago

Sure, assigning it to you. Feel free to join our discord server if you need help with anything

sameer1612 commented 11 months ago

@SankethBK seems blocked here. Flutter's native expansion panel is broken. Doesn't even work on the official website. https://api.flutter.dev/flutter/material/ExpansionPanelList-class.html

Another option we had was to use Accordion library which has a bug with transparent background. I raised an issue but can't expect a resolution soon. https://github.com/GotJimmy/accordion/issues/55

Only option we have in hand is to use a deep blue color instead of waiting for transparent background support. What you suggest?

SankethBK commented 11 months ago

@sameer1612 how about creating our own accordion widget?

Not sure if AnimatedCrossFade would work here. If not we may have to use AnimatedSize or something. Let me know if this helps

import 'package:flutter/material.dart';

class CustomAccordion extends StatefulWidget {
  final Widget header;
  final List<Widget> children;

  CustomAccordion({required this.header, required this.children});

  @override
  _SmoothAccordionState createState() => _SmoothAccordionState();
}

class _CustomAccordionState extends State<Accordion> {
  bool _isExpanded = false;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ListTile(
          title: widget.header,
          onTap: () {
            setState(() {
              _isExpanded = !_isExpanded;
            });
          },
          trailing: _isExpanded ? Icon(Icons.expand_less) : Icon(Icons.expand_more),
        ),
        AnimatedCrossFade(
          firstChild: Container(),
          secondChild: Column(
            children: widget.children,
          ),
          crossFadeState: _isExpanded ? CrossFadeState.showSecond : CrossFadeState.showFirst,
          duration: Duration(milliseconds: 300), // Adjust the duration as needed
        ),
        Divider(height: 1), // Add a divider to separate accordions
      ],
    );
  }
}

We can use it as


CustomAccordion(header: Text("Security Settings", children: [
    Text("change password), ...
])
sameer1612 commented 11 months ago

@SankethBK Luckily landed up with a library that doesn't mess up with glassmorphic design. Looks good!

ezgif com-video-to-gif

Here's a PR: https://github.com/SankethBK/diaryvault/pull/48