more contact wiring, adding contactrow, more bugfixes
This commit is contained in:
parent
88d8c432e6
commit
fe4a4c9f75
|
@ -155,6 +155,12 @@ class ProfileInfoState extends ChangeNotifier {
|
||||||
this._unreadMessages = newVal;
|
this._unreadMessages = newVal;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
super.dispose();
|
||||||
|
print("profileinfostate.dispose()");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContactInfoState extends ChangeNotifier {
|
class ContactInfoState extends ChangeNotifier {
|
||||||
|
|
|
@ -1,11 +1,8 @@
|
||||||
import 'dart:collection';
|
|
||||||
import 'dart:convert';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_app/widgets/contactrow.dart';
|
||||||
import 'package:provider/provider.dart';
|
import 'package:provider/provider.dart';
|
||||||
import '../main.dart';
|
import '../main.dart';
|
||||||
import '../opaque.dart';
|
|
||||||
import 'addcontactview.dart';
|
import 'addcontactview.dart';
|
||||||
import 'messageview.dart';
|
|
||||||
import '../model.dart';
|
import '../model.dart';
|
||||||
|
|
||||||
class ContactsView extends StatefulWidget {
|
class ContactsView extends StatefulWidget {
|
||||||
|
@ -61,30 +58,9 @@ class _ContactsViewState extends State<ContactsView> {
|
||||||
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
|
||||||
final tiles = Provider.of<ContactListState>(context).onions.map(
|
final tiles = Provider.of<ContactListState>(context).onions.map(
|
||||||
(ContactInfoState contact) {
|
(ContactInfoState contact) {
|
||||||
return ListTile(
|
return ChangeNotifierProvider<ContactInfoState>(
|
||||||
leading: SizedBox(
|
create: (context) => contact,
|
||||||
width: 60,
|
builder: (context, child) => ContactRow(),
|
||||||
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);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -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() {
|
void _pushAddContact() {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
MaterialPageRoute<void>(
|
||||||
|
|
|
@ -107,7 +107,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
|
||||||
(ProfileInfoState profile) {
|
(ProfileInfoState profile) {
|
||||||
return ChangeNotifierProvider<ProfileInfoState>(
|
return ChangeNotifierProvider<ProfileInfoState>(
|
||||||
create: (context) => profile,
|
create: (context) => profile,
|
||||||
builder: (context, child) => ProfileRow(profile),
|
builder: (context, child) => ProfileRow(),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
|
@ -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),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
|
@ -9,9 +9,6 @@ import '../model.dart';
|
||||||
import '../opaque.dart';
|
import '../opaque.dart';
|
||||||
|
|
||||||
class ProfileRow extends StatefulWidget {
|
class ProfileRow extends StatefulWidget {
|
||||||
final ProfileInfoState profile;
|
|
||||||
ProfileRow(this.profile);
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
_ProfileRowState createState() => _ProfileRowState();
|
_ProfileRowState createState() => _ProfileRowState();
|
||||||
}
|
}
|
||||||
|
@ -19,35 +16,36 @@ class ProfileRow extends StatefulWidget {
|
||||||
class _ProfileRowState extends State<ProfileRow> {
|
class _ProfileRowState extends State<ProfileRow> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
var profile = Provider.of<ProfileInfoState>(context);
|
||||||
return ListTile(
|
return ListTile(
|
||||||
leading: SizedBox(
|
leading: SizedBox(
|
||||||
width: 60,
|
width: 60,
|
||||||
height: 60,
|
height: 60,
|
||||||
child: ClipOval(
|
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(
|
trailing: IconButton(
|
||||||
icon: Icon(Icons.create, color: Provider.of<OpaqueTheme>(context).current().mainTextColor()),
|
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)
|
),//(nb: Icons.create is a pencil and we use it for "edit", not create)
|
||||||
title: Text(
|
title: Text(
|
||||||
widget.profile.nickname,
|
profile.nickname,
|
||||||
style: Provider.of<FlwtchState>(context).biggerFont,
|
style: Provider.of<FlwtchState>(context).biggerFont,
|
||||||
),
|
),
|
||||||
subtitle: Text(widget.profile.onion),
|
subtitle: Text(profile.onion),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
var flwtch = Provider.of<FlwtchState>(context, listen:false);
|
var flwtch = Provider.of<FlwtchState>(context, listen:false);
|
||||||
flwtch.cwtch.SelectProfile(widget.profile.onion);
|
flwtch.cwtch.SelectProfile(profile.onion);
|
||||||
flwtch.setState(() {
|
flwtch.setState(() {
|
||||||
flwtch.selectedProfile = widget.profile;
|
flwtch.selectedProfile = profile;
|
||||||
flwtch.selectedConversation = "";
|
flwtch.selectedConversation = "";
|
||||||
});
|
});
|
||||||
|
|
||||||
switch (flwtch.columns.length) {
|
switch (flwtch.columns.length) {
|
||||||
case 1: _pushContactList(widget.profile, false); break;
|
case 1: _pushContactList(profile, false); break;
|
||||||
case 2: _pushContactList(widget.profile, true); break;
|
case 2: _pushContactList(profile, true); break;
|
||||||
} // case 3: handled by TripleColumnView
|
} // case 3: handled by TripleColumnView
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -57,11 +55,11 @@ class _ProfileRowState extends State<ProfileRow> {
|
||||||
void _pushContactList(ProfileInfoState profile, bool includeDoublePane) {
|
void _pushContactList(ProfileInfoState profile, bool includeDoublePane) {
|
||||||
Navigator.of(context).push(
|
Navigator.of(context).push(
|
||||||
MaterialPageRoute<void>(
|
MaterialPageRoute<void>(
|
||||||
builder: (BuildContext context) {
|
builder: (BuildContext buildcontext) {
|
||||||
return MultiProvider(
|
return MultiProvider(
|
||||||
providers: [
|
providers: [
|
||||||
ChangeNotifierProvider<ProfileInfoState>(create: (_) => profile),
|
ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
|
||||||
ChangeNotifierProvider<ContactListState>(create: (_) => ContactListState(Provider.of<FlwtchState>(context).cwtch, profile.onion),),
|
ChangeNotifierProvider<ContactListState>(create: (_) => ContactListState(Provider.of<FlwtchState>(buildcontext).cwtch, profile.onion),),
|
||||||
],
|
],
|
||||||
builder: (context, widget) => includeDoublePane ? DoubleColumnView() : ContactsView(),
|
builder: (context, widget) => includeDoublePane ? DoubleColumnView() : ContactsView(),
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue