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:flutter_gen/gen_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( 28 0 : key: widget.key, 29 : ), 30 : ), 31 0 : Flexible( 32 0 : flex: cols[1], 33 : child: selectedConversation == null 34 0 : ? Container( 35 0 : color: Provider.of<Settings>(context).theme.backgroundMainColor, 36 0 : child: Card( 37 0 : margin: EdgeInsets.all(0.0), 38 0 : shape: new RoundedRectangleBorder(side: new BorderSide(color: Provider.of<Settings>(context).theme.defaultButtonColor, width: 4.0), borderRadius: BorderRadius.circular(4.0)), 39 0 : child: Center(child: Text(AppLocalizations.of(context)!.addContactFirst)))) 40 : : //dev 41 0 : MultiProvider(providers: [ 42 0 : ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context)), 43 : // there is a potential timing issue here where selectConversation is changes as we move profiles, this will result 44 : // in getContact being null, in that case we replace with an empty Contact Info State 45 0 : ChangeNotifierProvider.value(value: Provider.of<ProfileInfoState>(context).contactList.getContact(selectedConversation) ?? ContactInfoState("", -1, "")), 46 0 : ], child: Container(key: Key(selectedConversation.toString()), child: MessageView())), 47 : ), 48 : ], 49 : ); 50 : } 51 : }