Line data Source code
1 : import 'package:cwtch/models/appstate.dart'; 2 : import 'package:cwtch/models/contact.dart'; 3 : import 'package:cwtch/models/profile.dart'; 4 : import 'package:flutter/material.dart'; 5 : import 'package:provider/provider.dart'; 6 : import 'package:cwtch/l10n/app_localizations.dart'; 7 : import '../settings.dart'; 8 : import 'contactsview.dart'; 9 : import 'messageview.dart'; 10 : 11 : class DoubleColumnView extends StatefulWidget { 12 0 : @override 13 0 : _DoubleColumnViewState createState() => _DoubleColumnViewState(); 14 : } 15 : 16 : class _DoubleColumnViewState extends State<DoubleColumnView> { 17 0 : @override 18 : Widget build(BuildContext context) { 19 0 : var flwtch = Provider.of<AppState>(context); 20 0 : var selectedConversation = flwtch.selectedConversation; 21 0 : var cols = Provider.of<Settings>(context).uiColumns(true); 22 0 : return Flex( 23 : direction: Axis.horizontal, 24 0 : children: <Widget>[ 25 0 : Flexible( 26 0 : flex: cols[0], 27 0 : child: ContactsView(key: widget.key), 28 : ), 29 0 : Flexible( 30 0 : flex: cols[1], 31 : child: selectedConversation == null 32 0 : ? Container( 33 0 : color: Provider.of<Settings>(context).theme.backgroundMainColor, 34 0 : child: Card( 35 0 : margin: EdgeInsets.all(0.0), 36 0 : color: Provider.of<Settings>(context).theme.backgroundMainColor, 37 0 : shape: new RoundedRectangleBorder( 38 0 : side: new BorderSide(color: Provider.of<Settings>(context).theme.defaultButtonColor, width: 4.0), 39 0 : borderRadius: BorderRadius.circular(4.0), 40 : ), 41 0 : child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)), 42 : ), 43 : ) 44 : : //dev 45 0 : MultiProvider( 46 0 : providers: [ 47 0 : ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)), 48 : // there is a potential timing issue here where selectConversation is changes as we move profiles, this will result 49 : // in getContact being null, in that case we replace with an empty Contact Info State 50 0 : ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).contactList.getContact(selectedConversation) ?? ContactInfoState("", -1, "")), 51 : ], 52 0 : child: Container(key: Key(selectedConversation.toString()), child: MessageView()), 53 : ), 54 : ), 55 : ], 56 : ); 57 : } 58 : }