more contact wiring, adding contactrow, more bugfixes

This commit is contained in:
erinn 2021-02-10 17:03:02 -08:00
parent 88d8c432e6
commit fe4a4c9f75
5 changed files with 80 additions and 56 deletions

View File

@ -155,6 +155,12 @@ class ProfileInfoState extends ChangeNotifier {
this._unreadMessages = newVal;
notifyListeners();
}
@override
void dispose() {
super.dispose();
print("profileinfostate.dispose()");
}
}
class ContactInfoState extends ChangeNotifier {

View File

@ -1,11 +1,8 @@
import 'dart:collection';
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter_app/widgets/contactrow.dart';
import 'package:provider/provider.dart';
import '../main.dart';
import '../opaque.dart';
import 'addcontactview.dart';
import 'messageview.dart';
import '../model.dart';
class ContactsView extends StatefulWidget {
@ -61,30 +58,9 @@ class _ContactsViewState extends State<ContactsView> {
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
final tiles = Provider.of<ContactListState>(context).onions.map(
(ContactInfoState contact) {
return ListTile(
leading: SizedBox(
width: 60,
height: 60,
child: ClipOval(
child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage("assets/profiles/001-centaur.png"), width:50,height:50,))),
//child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage(contact.imagePath), width:50,height:50,))),
),
),
trailing: contact.isInvitation != null && contact.isInvitation ? Column(children:<Widget>[Icon(Icons.favorite, color: Opaque.current().mainTextColor()),Icon(Icons.delete, color: Opaque.current().mainTextColor())]) : Text("99+"),//(nb: Icons.create is a pencil and we use it for "edit", not create)
title: Text(
contact.nickname,
style: Provider.of<FlwtchState>(context).biggerFont,
),
subtitle: Text(contact.status),
onTap: () {
setState(() {
var flwtch = Provider.of<FlwtchState>(context, listen:false);
flwtch.setState(() => flwtch.selectedConversation = contact.onion);
// case 2/3 handled by Double/TripleColumnView respectively
if (flwtch.columns.length == 1) _pushMessageView(contact.onion);
});
},
return ChangeNotifierProvider<ContactInfoState>(
create: (context) => contact,
builder: (context, child) => ContactRow(),
);
},
);
@ -99,19 +75,6 @@ class _ContactsViewState extends State<ContactsView> {
);
}
void _pushMessageView(String handle) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext builderContext) {
return MultiProvider(
providers: [ChangeNotifierProvider<ProfileInfoState>(create: (_) => Provider.of<ProfileInfoState>(context)),],
child: MessageView(conversationHandle: handle),
);
},
),
);
}
void _pushAddContact() {
Navigator.of(context).push(
MaterialPageRoute<void>(

View File

@ -107,7 +107,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
(ProfileInfoState profile) {
return ChangeNotifierProvider<ProfileInfoState>(
create: (context) => profile,
builder: (context, child) => ProfileRow(profile),
builder: (context, child) => ProfileRow(),
);
},
);

View File

@ -0,0 +1,57 @@
import 'package:flutter/material.dart';
import 'package:flutter_app/views/messageview.dart';
import 'package:provider/provider.dart';
import '../main.dart';
import '../model.dart';
import '../opaque.dart';
class ContactRow extends StatefulWidget {
@override
_ContactRowState createState() => _ContactRowState();
}
class _ContactRowState extends State<ContactRow> {
@override
Widget build(BuildContext context) {
var contact = Provider.of<ContactInfoState>(context);
return ListTile(
leading: SizedBox(
width: 60,
height: 60,
child: ClipOval(
child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage("assets/profiles/001-centaur.png"), width:50,height:50,))),
//child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage(contact.imagePath), width:50,height:50,))),
),
),
trailing: contact.isInvitation != null && contact.isInvitation ? Column(children:<Widget>[Icon(Icons.favorite, color: Opaque.current().mainTextColor()),Icon(Icons.delete, color: Opaque.current().mainTextColor())]) : Text("99+"),//(nb: Icons.create is a pencil and we use it for "edit", not create)
title: Text(
contact.nickname,
style: Provider.of<FlwtchState>(context).biggerFont,
),
subtitle: Text(contact.status),
onTap: () {
setState(() {
var flwtch = Provider.of<FlwtchState>(context, listen:false);
flwtch.setState(() => flwtch.selectedConversation = contact.onion);
// case 2/3 handled by Double/TripleColumnView respectively
if (flwtch.columns.length == 1) _pushMessageView(contact.onion);
});
},
);
}
void _pushMessageView(String handle) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext builderContext) {
return MultiProvider(
providers: [ChangeNotifierProvider<ProfileInfoState>(create: (_) => Provider.of<ProfileInfoState>(context)),],
child: MessageView(conversationHandle: handle),
);
},
),
);
}
}

View File

@ -9,9 +9,6 @@ import '../model.dart';
import '../opaque.dart';
class ProfileRow extends StatefulWidget {
final ProfileInfoState profile;
ProfileRow(this.profile);
@override
_ProfileRowState createState() => _ProfileRowState();
}
@ -19,35 +16,36 @@ class ProfileRow extends StatefulWidget {
class _ProfileRowState extends State<ProfileRow> {
@override
Widget build(BuildContext context) {
var profile = Provider.of<ProfileInfoState>(context);
return ListTile(
leading: SizedBox(
width: 60,
height: 60,
child: ClipOval(
child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage("assets/" + widget.profile.imagePath), width:50,height:50,))),
child: SizedBox(width:60, height:60, child:Container(color:Colors.white, width: 60, height: 60, child: Image(image: AssetImage("assets/" + profile.imagePath), width:50,height:50,))),
),
) ,
trailing: IconButton(
icon: Icon(Icons.create, color: Provider.of<OpaqueTheme>(context).current().mainTextColor()),
onPressed: () { _pushAddEditProfile(onion: widget.profile.onion); },
onPressed: () { _pushAddEditProfile(onion: profile.onion); },
),//(nb: Icons.create is a pencil and we use it for "edit", not create)
title: Text(
widget.profile.nickname,
profile.nickname,
style: Provider.of<FlwtchState>(context).biggerFont,
),
subtitle: Text(widget.profile.onion),
subtitle: Text(profile.onion),
onTap: () {
setState(() {
var flwtch = Provider.of<FlwtchState>(context, listen:false);
flwtch.cwtch.SelectProfile(widget.profile.onion);
flwtch.cwtch.SelectProfile(profile.onion);
flwtch.setState(() {
flwtch.selectedProfile = widget.profile;
flwtch.selectedProfile = profile;
flwtch.selectedConversation = "";
});
switch (flwtch.columns.length) {
case 1: _pushContactList(widget.profile, false); break;
case 2: _pushContactList(widget.profile, true); break;
case 1: _pushContactList(profile, false); break;
case 2: _pushContactList(profile, true); break;
} // case 3: handled by TripleColumnView
});
},
@ -57,11 +55,11 @@ class _ProfileRowState extends State<ProfileRow> {
void _pushContactList(ProfileInfoState profile, bool includeDoublePane) {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (BuildContext context) {
builder: (BuildContext buildcontext) {
return MultiProvider(
providers: [
ChangeNotifierProvider<ProfileInfoState>(create: (_) => profile),
ChangeNotifierProvider<ContactListState>(create: (_) => ContactListState(Provider.of<FlwtchState>(context).cwtch, profile.onion),),
ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
ChangeNotifierProvider<ContactListState>(create: (_) => ContactListState(Provider.of<FlwtchState>(buildcontext).cwtch, profile.onion),),
],
builder: (context, widget) => includeDoublePane ? DoubleColumnView() : ContactsView(),
);