android/ios-adaption feature, markdown, and augment #6
					 1 changed files with 64 additions and 40 deletions
				
			
		| 
						 | 
				
			
			@ -27,13 +27,14 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
			
		|||
  List heightOfViewTypes = []; //the height of each viewtype
 | 
			
		||||
  List<SerializableMessage> emailsInThread = [];
 | 
			
		||||
  bool _isLoaded = false;
 | 
			
		||||
  static bool _isListenerRegistered = false;
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  void initState() {
 | 
			
		||||
    // TODO: implement initState
 | 
			
		||||
    super.initState();
 | 
			
		||||
    _registerViewFactory(widget.threadHTML);
 | 
			
		||||
    _serializableData(widget.threadIDs);
 | 
			
		||||
    _serializableData(widget.threadIDs); // this
 | 
			
		||||
    _keyListener();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void _registerViewFactory(List<String> currentContent) async {
 | 
			
		||||
| 
						 | 
				
			
			@ -88,6 +89,30 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
			
		|||
    });
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  void _keyListener() {
 | 
			
		||||
    if (_isListenerRegistered) return;
 | 
			
		||||
    _isListenerRegistered = true;
 | 
			
		||||
    web.window.document.addEventListener(
 | 
			
		||||
      'keydown',
 | 
			
		||||
      ((web.Event event) {
 | 
			
		||||
        final keyEvent = event as web.KeyboardEvent;
 | 
			
		||||
 | 
			
		||||
        if (keyEvent.key.toLowerCase() == 'k') {
 | 
			
		||||
          print('You pressed the "k" key!');
 | 
			
		||||
          final leftPurpleNums = web.document.getElementsByClassName("right");
 | 
			
		||||
 | 
			
		||||
          for (int i = 0; i < leftPurpleNums.length; i++) {
 | 
			
		||||
            final currentElement = leftPurpleNums.item(i) as web.HTMLElement;
 | 
			
		||||
            final opacity = web.window.getComputedStyle(currentElement).opacity;
 | 
			
		||||
            
 | 
			
		||||
            currentElement.style.opacity =
 | 
			
		||||
                (opacity == '0') ? '1.0' : '0.0'; // works mostly
 | 
			
		||||
          }
 | 
			
		||||
        }
 | 
			
		||||
      }).toJS,
 | 
			
		||||
    );
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  @override
 | 
			
		||||
  Widget build(BuildContext context) {
 | 
			
		||||
    return _isLoaded
 | 
			
		||||
| 
						 | 
				
			
			@ -96,8 +121,8 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
			
		|||
              child: ListView.builder(
 | 
			
		||||
                itemCount: widget.thread.length,
 | 
			
		||||
                itemBuilder: (context, index) {
 | 
			
		||||
              final isExpanded =
 | 
			
		||||
                  _expandedEmails.contains(index); //check if email is expanded
 | 
			
		||||
                  final isExpanded = _expandedEmails
 | 
			
		||||
                      .contains(index); //check if email is expanded
 | 
			
		||||
                  return Column(
 | 
			
		||||
                    children: [
 | 
			
		||||
                      ListTile(
 | 
			
		||||
| 
						 | 
				
			
			@ -114,8 +139,6 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
			
		|||
                        },
 | 
			
		||||
                      ),
 | 
			
		||||
                      if (isExpanded)
 | 
			
		||||
                    // if(viewtypeIDs[index] == null || heightOfViewTypes[index] == null)
 | 
			
		||||
                    //   const SizedBox(height: 100, child: Center(child: CircularProgressIndicator())),
 | 
			
		||||
                        SizedBox(
 | 
			
		||||
                          height: heightOfViewTypes[index].toDouble(),
 | 
			
		||||
                          child: HtmlElementView(
 | 
			
		||||
| 
						 | 
				
			
			@ -127,6 +150,7 @@ class _CollapsableEmailsState extends State<CollapsableEmails> {
 | 
			
		|||
                },
 | 
			
		||||
              ),
 | 
			
		||||
            )
 | 
			
		||||
    ]): const Center(child:CircularProgressIndicator());
 | 
			
		||||
          ])
 | 
			
		||||
        : const Center(child: CircularProgressIndicator());
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue