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 heightOfViewTypes = []; //the height of each viewtype
 | 
				
			||||||
  List<SerializableMessage> emailsInThread = [];
 | 
					  List<SerializableMessage> emailsInThread = [];
 | 
				
			||||||
  bool _isLoaded = false;
 | 
					  bool _isLoaded = false;
 | 
				
			||||||
 | 
					  static bool _isListenerRegistered = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @override
 | 
					  @override
 | 
				
			||||||
  void initState() {
 | 
					  void initState() {
 | 
				
			||||||
    // TODO: implement initState
 | 
					 | 
				
			||||||
    super.initState();
 | 
					    super.initState();
 | 
				
			||||||
    _registerViewFactory(widget.threadHTML);
 | 
					    _registerViewFactory(widget.threadHTML);
 | 
				
			||||||
    _serializableData(widget.threadIDs);
 | 
					    _serializableData(widget.threadIDs); // this
 | 
				
			||||||
 | 
					    _keyListener();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  void _registerViewFactory(List<String> currentContent) async {
 | 
					  void _registerViewFactory(List<String> currentContent) async {
 | 
				
			||||||
| 
						 | 
					@ -88,45 +89,68 @@ 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
 | 
					  @override
 | 
				
			||||||
  Widget build(BuildContext context) {
 | 
					  Widget build(BuildContext context) {
 | 
				
			||||||
    return _isLoaded 
 | 
					    return _isLoaded
 | 
				
			||||||
      ?Column(children: [
 | 
					        ? Column(children: [
 | 
				
			||||||
        Expanded(
 | 
					            Expanded(
 | 
				
			||||||
          child: ListView.builder(
 | 
					              child: ListView.builder(
 | 
				
			||||||
            itemCount: widget.thread.length,
 | 
					                itemCount: widget.thread.length,
 | 
				
			||||||
            itemBuilder: (context, index) {
 | 
					                itemBuilder: (context, index) {
 | 
				
			||||||
              final isExpanded =
 | 
					                  final isExpanded = _expandedEmails
 | 
				
			||||||
                  _expandedEmails.contains(index); //check if email is expanded
 | 
					                      .contains(index); //check if email is expanded
 | 
				
			||||||
              return Column(
 | 
					                  return Column(
 | 
				
			||||||
                children: [
 | 
					                    children: [
 | 
				
			||||||
                  ListTile(
 | 
					                      ListTile(
 | 
				
			||||||
                    title: Text(emailsInThread[index].from),
 | 
					                        title: Text(emailsInThread[index].from),
 | 
				
			||||||
                    trailing: Text(emailsInThread[index].date),
 | 
					                        trailing: Text(emailsInThread[index].date),
 | 
				
			||||||
                    onTap: () {
 | 
					                        onTap: () {
 | 
				
			||||||
                      setState(() {
 | 
					                          setState(() {
 | 
				
			||||||
                        if (isExpanded) {
 | 
					                            if (isExpanded) {
 | 
				
			||||||
                          _expandedEmails.remove(index);
 | 
					                              _expandedEmails.remove(index);
 | 
				
			||||||
                        } else {
 | 
					                            } else {
 | 
				
			||||||
                          _expandedEmails.add(index);
 | 
					                              _expandedEmails.add(index);
 | 
				
			||||||
                        }
 | 
					                            }
 | 
				
			||||||
                      });
 | 
					                          });
 | 
				
			||||||
                    },
 | 
					                        },
 | 
				
			||||||
                  ),
 | 
					                      ),
 | 
				
			||||||
                  if (isExpanded)
 | 
					                      if (isExpanded)
 | 
				
			||||||
                    // if(viewtypeIDs[index] == null || heightOfViewTypes[index] == null)
 | 
					                        SizedBox(
 | 
				
			||||||
                    //   const SizedBox(height: 100, child: Center(child: CircularProgressIndicator())),
 | 
					                          height: heightOfViewTypes[index].toDouble(),
 | 
				
			||||||
                    SizedBox(
 | 
					                          child: HtmlElementView(
 | 
				
			||||||
                      height: heightOfViewTypes[index].toDouble(),
 | 
					                              key: UniqueKey(), viewType: viewtypeIDs[index]),
 | 
				
			||||||
                      child: HtmlElementView(
 | 
					                        ),
 | 
				
			||||||
                          key: UniqueKey(), viewType: viewtypeIDs[index]),
 | 
					                      Divider(),
 | 
				
			||||||
                    ),
 | 
					                    ],
 | 
				
			||||||
                  Divider(),
 | 
					                  );
 | 
				
			||||||
                ],
 | 
					                },
 | 
				
			||||||
              );
 | 
					              ),
 | 
				
			||||||
            },
 | 
					            )
 | 
				
			||||||
          ),
 | 
					          ])
 | 
				
			||||||
        )
 | 
					        : const Center(child: CircularProgressIndicator());
 | 
				
			||||||
    ]): const Center(child:CircularProgressIndicator());
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue