merging to trunk

This commit is contained in:
erinn 2021-03-17 12:33:35 -07:00
commit e3bfb109a6
41 changed files with 663 additions and 1247 deletions

View File

@ -47,7 +47,7 @@ required - any new Cwtch work is beyond the scope of this initial spec.
- [X] Save/Load - [X] Save/Load
- [X] Switch Dark / Light Theme - [X] Switch Dark / Light Theme
- [X] Switch Language - [X] Switch Language
- [ ] Enable/Disable Experiments - [X] Enable/Disable Experiments
- [ ] Accessibility Settings (Zoom etc. - needs a deep dive into flutter) - [ ] Accessibility Settings (Zoom etc. - needs a deep dive into flutter)
- [X] Display Build & Version Info - [X] Display Build & Version Info
- [X] Acknowledgements & Credits - [X] Acknowledgements & Credits

View File

@ -64,4 +64,6 @@ dependencies {
implementation project(':cwtch') implementation project(':cwtch')
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.2"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2" implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.2"
implementation "com.airbnb.android:lottie:3.5.0"
implementation "com.android.support.constraint:constraint-layout:2.0.4"
} }

View File

@ -12,7 +12,7 @@
<activity <activity
android:name=".MainActivity" android:name=".MainActivity"
android:launchMode="singleTop" android:launchMode="singleTop"
android:theme="@style/LaunchTheme" android:theme="@style/NormalTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true" android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize"> android:windowSoftInputMode="adjustResize">
@ -24,15 +24,7 @@
android:name="io.flutter.embedding.android.NormalTheme" android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme" android:resource="@style/NormalTheme"
/> />
<!-- Displays an Android View that continues showing the launch screen
Drawable until Flutter paints its first frame, then this splash
screen fades out. A splash screen is useful to avoid any visual
gap between the end of Android's launch screen and the painting of
Flutter's first frame. -->
<meta-data
android:name="io.flutter.embedding.android.SplashScreenDrawable"
android:resource="@drawable/launch_background"
/>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN"/> <action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/> <category android:name="android.intent.category.LAUNCHER"/>

View File

@ -1,5 +1,6 @@
package com.example.flutter_app package com.example.flutter_app
import SplashView
import androidx.annotation.NonNull import androidx.annotation.NonNull
import android.content.pm.PackageManager import android.content.pm.PackageManager
import android.os.Bundle import android.os.Bundle
@ -10,6 +11,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import io.flutter.embedding.android.SplashScreen
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.MethodChannel import io.flutter.plugin.common.MethodChannel
@ -25,6 +27,8 @@ import org.json.JSONObject
class MainActivity: FlutterActivity() { class MainActivity: FlutterActivity() {
override fun provideSplashScreen(): SplashScreen? = SplashView()
// Channel to get app info // Channel to get app info
private val CHANNEL_APP_INFO = "test.flutter.dev/applicationInfo" private val CHANNEL_APP_INFO = "test.flutter.dev/applicationInfo"
private val CALL_APP_INFO = "getNativeLibDir" private val CALL_APP_INFO = "getNativeLibDir"

View File

@ -0,0 +1,15 @@
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import com.example.flutter_app.R
import io.flutter.embedding.android.SplashScreen
class SplashView : SplashScreen {
override fun createSplashView(context: Context, savedInstanceState: Bundle?): View? =
LayoutInflater.from(context).inflate(R.layout.splash_view, null, false)
override fun transitionToFlutter(onTransitionComplete: Runnable) {
onTransitionComplete.run()
}
}

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.airbnb.lottie.LottieAnimationView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:lottie_autoPlay="true"
app:lottie_rawRes="@raw/cwtch_animated_logo"
app:lottie_loop="true"
app:lottie_speed="1.00" />
</androidx.constraintlayout.widget.ConstraintLayout>

File diff suppressed because one or more lines are too long

View File

@ -1,18 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Theme applied to the Android Window while the process is starting -->
<style name="LaunchTheme" parent="@android:style/Theme.Black.NoTitleBar">
<!-- Show a splash screen on the activity. Automatically removed when
Flutter draws its first frame -->
<item name="android:windowBackground">@drawable/launch_background</item>
</style>
<!-- Theme applied to the Android Window as soon as the process has started.
This theme determines the color of the Android Window while your
Flutter UI initializes, as well as behind your Flutter UI while its
running.
This Theme is only used starting with V2 of Flutter's Android embedding. -->
<style name="NormalTheme" parent="@android:style/Theme.Black.NoTitleBar">
<item name="android:windowBackground">@android:color/white</item>
</style>
</resources>

View File

@ -8,6 +8,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.5.0' classpath 'com.android.tools.build:gradle:3.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }

Binary file not shown.

View File

@ -21,31 +21,32 @@ class CwtchNotifier {
switch (type) { switch (type) {
case "NewPeer": case "NewPeer":
profileCN.add(ProfileInfoState( profileCN.add(ProfileInfoState(
onion: data["Identity"], onion: data["Identity"],
nickname: data["name"], nickname: data["name"],
imagePath: data["picture"], imagePath: data["picture"],
contactsJson: data["ContactsJson"], contactsJson: data["ContactsJson"],
)); ));
break; break;
case "PeerCreated": case "PeerCreated":
print("xx peercreated"); print("xx peercreated");
profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState( profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState(
profileOnion: data["ProfileOnion"], profileOnion: data["ProfileOnion"],
onion: data["RemotePeer"], onion: data["RemotePeer"],
nickname: data["nick"], nickname: data["nick"],
status: data["status"], status: data["status"],
)); ));
break; break;
case "PeerStateChange": case "PeerStateChange":
ContactInfoState contact = profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["RemotePeer"]); ContactInfoState contact = profileCN.getProfile(data["ProfileOnion"]).contactList.getContact(data["RemotePeer"]);
if (contact == null) {//todo: stopgap, as lc-g is supposed to handle this if (contact == null) {
print("PSC -> adding "+data["ProfileOnion"]+" :: " + data["RemotePeer"]); //todo: stopgap, as lc-g is supposed to handle this
print("PSC -> adding " + data["ProfileOnion"] + " :: " + data["RemotePeer"]);
profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState( profileCN.getProfile(data["ProfileOnion"]).contactList.add(ContactInfoState(
profileOnion: data["ProfileOnion"], profileOnion: data["ProfileOnion"],
onion: data["RemotePeer"], onion: data["RemotePeer"],
nickname: data["nick"], nickname: data["nick"],
status: data["ConnectionState"], status: data["ConnectionState"],
)); ));
} else { } else {
contact.status = data["ConnectionState"]; contact.status = data["ConnectionState"];
} }

View File

@ -15,52 +15,38 @@ import '../model.dart';
/// Cwtch API /// /// Cwtch API ///
///////////////////// /////////////////////
typedef start_cwtch_function = Void Function( typedef start_cwtch_function = Void Function(Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2);
Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2); typedef StartCwtchFn = void Function(Pointer<Utf8> dir, int len, Pointer<Utf8> tor, int torLen);
typedef StartCwtchFn = void Function(
Pointer<Utf8> dir, int len, Pointer<Utf8> tor, int torLen);
typedef void_from_string_string_function = Void Function( typedef void_from_string_string_function = Void Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
Pointer<Utf8>, Int32, Pointer<Utf8>, Int32); typedef VoidFromStringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int);
typedef VoidFromStringStringFn = void Function(
Pointer<Utf8>, int, Pointer<Utf8>, int);
typedef access_cwtch_eventbus_function = Void Function(); typedef access_cwtch_eventbus_function = Void Function();
typedef NextEventFn = void Function(); typedef NextEventFn = void Function();
typedef string_to_void_function = Void Function( typedef string_to_void_function = Void Function(Pointer<Utf8> str, Int32 length);
Pointer<Utf8> str, Int32 length);
typedef StringFn = void Function(Pointer<Utf8> dir, int); typedef StringFn = void Function(Pointer<Utf8> dir, int);
typedef string_string_to_void_function = Void Function( typedef string_string_to_void_function = Void Function(Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2);
Pointer<Utf8> str, Int32 length, Pointer<Utf8> str2, Int32 length2);
typedef StringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int); typedef StringStringFn = void Function(Pointer<Utf8>, int, Pointer<Utf8>, int);
typedef get_json_blob_void_function = Pointer<Utf8> Function(); typedef get_json_blob_void_function = Pointer<Utf8> Function();
typedef GetJsonBlobVoidFn = Pointer<Utf8> Function(); typedef GetJsonBlobVoidFn = Pointer<Utf8> Function();
typedef get_json_blob_string_function = Pointer<Utf8> Function( typedef get_json_blob_string_function = Pointer<Utf8> Function(Pointer<Utf8> str, Int32 length);
Pointer<Utf8> str, Int32 length); typedef GetJsonBlobStringFn = Pointer<Utf8> Function(Pointer<Utf8> str, int len);
typedef GetJsonBlobStringFn = Pointer<Utf8> Function(
Pointer<Utf8> str, int len);
//func NumMessages(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int) (n C.int) { //func NumMessages(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int) (n C.int) {
typedef get_int_from_str_str_function = Int32 Function( typedef get_int_from_str_str_function = Int32 Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32);
Pointer<Utf8>, Int32, Pointer<Utf8>, Int32); typedef GetIntFromStrStrFn = int Function(Pointer<Utf8>, int, Pointer<Utf8>, int);
typedef GetIntFromStrStrFn = int Function(
Pointer<Utf8>, int, Pointer<Utf8>, int);
//func GetMessage(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, message_index C.int) *C.char { //func GetMessage(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, message_index C.int) *C.char {
typedef get_json_blob_from_str_str_int_function = Pointer<Utf8> Function( typedef get_json_blob_from_str_str_int_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32);
Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32); typedef GetJsonBlobFromStrStrIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int);
typedef GetJsonBlobFromStrStrIntFn = Pointer<Utf8> Function(
Pointer<Utf8>, int, Pointer<Utf8>, int, int);
//func GetMessages(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, start C.int, end C.int) *C.char { //func GetMessages(profile_ptr *C.char, profile_len C.int, handle_ptr *C.char, handle_len C.int, start C.int, end C.int) *C.char {
typedef get_json_blob_from_str_str_int_int_function = Pointer<Utf8> Function( typedef get_json_blob_from_str_str_int_int_function = Pointer<Utf8> Function(Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32, Int32);
Pointer<Utf8>, Int32, Pointer<Utf8>, Int32, Int32, Int32); typedef GetJsonBlobFromStrStrIntIntFn = Pointer<Utf8> Function(Pointer<Utf8>, int, Pointer<Utf8>, int, int, int);
typedef GetJsonBlobFromStrStrIntIntFn = Pointer<Utf8> Function(
Pointer<Utf8>, int, Pointer<Utf8>, int, int, int);
typedef acn_events_function = Pointer<Utf8> Function(); typedef acn_events_function = Pointer<Utf8> Function();
typedef ACNEventsFn = Pointer<Utf8> Function(); typedef ACNEventsFn = Pointer<Utf8> Function();
@ -86,8 +72,7 @@ class CwtchFfi implements Cwtch {
var cwtchDir = path.join(home, ".cwtch/dev/"); var cwtchDir = path.join(home, ".cwtch/dev/");
print("cwtchDir $cwtchDir"); print("cwtchDir $cwtchDir");
var startCwtchC = var startCwtchC = library.lookup<NativeFunction<start_cwtch_function>>("c_StartCwtch");
library.lookup<NativeFunction<start_cwtch_function>>("c_StartCwtch");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final StartCwtch = startCwtchC.asFunction<StartCwtchFn>(); final StartCwtch = startCwtchC.asFunction<StartCwtchFn>();
@ -96,8 +81,7 @@ class CwtchFfi implements Cwtch {
// Spawn an isolate to listen to events from libcwtch-go and then dispatch them when received on main thread to cwtchNotifier // Spawn an isolate to listen to events from libcwtch-go and then dispatch them when received on main thread to cwtchNotifier
var _receivePort = ReceivePort(); var _receivePort = ReceivePort();
cwtchIsolate = cwtchIsolate = await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort);
await Isolate.spawn(_checkAppbusEvents, _receivePort.sendPort);
_receivePort.listen((message) { _receivePort.listen((message) {
var env = jsonDecode(message); var env = jsonDecode(message);
cwtchNotifier.handleMessage(env["EventType"], env["Data"]); cwtchNotifier.handleMessage(env["EventType"], env["Data"]);
@ -123,8 +107,7 @@ class CwtchFfi implements Cwtch {
// Steam of appbus events. Call blocks in libcwtch-go GetAppbusEvent. Static so the isolate can use it // Steam of appbus events. Call blocks in libcwtch-go GetAppbusEvent. Static so the isolate can use it
static Stream<String> pollAppbusEvents() async* { static Stream<String> pollAppbusEvents() async* {
var library = DynamicLibrary.open("libCwtch.so"); var library = DynamicLibrary.open("libCwtch.so");
var getAppbusEventC = var getAppbusEventC = library.lookup<NativeFunction<acn_events_function>>("c_GetAppBusEvent");
library.lookup<NativeFunction<acn_events_function>>("c_GetAppBusEvent");
final GetAppbusEvent = getAppbusEventC.asFunction<ACNEventsFn>(); final GetAppbusEvent = getAppbusEventC.asFunction<ACNEventsFn>();
while (true) { while (true) {
@ -136,9 +119,7 @@ class CwtchFfi implements Cwtch {
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void SelectProfile(String onion) async { void SelectProfile(String onion) async {
var selectProfileC = var selectProfileC = library.lookup<NativeFunction<get_json_blob_string_function>>("c_SelectProfile");
library.lookup<NativeFunction<get_json_blob_string_function>>(
"c_SelectProfile");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final SelectProfile = selectProfileC.asFunction<GetJsonBlobStringFn>(); final SelectProfile = selectProfileC.asFunction<GetJsonBlobStringFn>();
final ut8Onion = onion.toNativeUtf8(); final ut8Onion = onion.toNativeUtf8();
@ -147,9 +128,7 @@ class CwtchFfi implements Cwtch {
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void CreateProfile(String nick, String pass) { void CreateProfile(String nick, String pass) {
var createProfileC = var createProfileC = library.lookup<NativeFunction<void_from_string_string_function>>("c_CreateProfile");
library.lookup<NativeFunction<void_from_string_string_function>>(
"c_CreateProfile");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final CreateProfile = createProfileC.asFunction<VoidFromStringStringFn>(); final CreateProfile = createProfileC.asFunction<VoidFromStringStringFn>();
final utf8nick = nick.toNativeUtf8(); final utf8nick = nick.toNativeUtf8();
@ -159,8 +138,7 @@ class CwtchFfi implements Cwtch {
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
void LoadProfiles(String pass) { void LoadProfiles(String pass) {
var loadProfileC = library var loadProfileC = library.lookup<NativeFunction<string_to_void_function>>("c_LoadProfiles");
.lookup<NativeFunction<string_to_void_function>>("c_LoadProfiles");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final LoadProfiles = loadProfileC.asFunction<StringFn>(); final LoadProfiles = loadProfileC.asFunction<StringFn>();
final ut8pass = pass.toNativeUtf8(); final ut8pass = pass.toNativeUtf8();
@ -168,8 +146,7 @@ class CwtchFfi implements Cwtch {
} }
Future<String> ACNEvents() async { Future<String> ACNEvents() async {
var acnEventsC = var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ACNEvents");
library.lookup<NativeFunction<acn_events_function>>("c_ACNEvents");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final ACNEvents = acnEventsC.asFunction<ACNEventsFn>(); final ACNEvents = acnEventsC.asFunction<ACNEventsFn>();
@ -179,8 +156,7 @@ class CwtchFfi implements Cwtch {
} }
Future<String> ContactEvents() async { Future<String> ContactEvents() async {
var acnEventsC = var acnEventsC = library.lookup<NativeFunction<acn_events_function>>("c_ContactEvents");
library.lookup<NativeFunction<acn_events_function>>("c_ContactEvents");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final ContactEvents = acnEventsC.asFunction<ACNEventsFn>(); final ContactEvents = acnEventsC.asFunction<ACNEventsFn>();
@ -190,8 +166,7 @@ class CwtchFfi implements Cwtch {
} }
Future<String> GetProfiles() async { Future<String> GetProfiles() async {
var getProfilesC = library var getProfilesC = library.lookup<NativeFunction<get_json_blob_void_function>>("c_GetProfiles");
.lookup<NativeFunction<get_json_blob_void_function>>("c_GetProfiles");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final GetProfiles = getProfilesC.asFunction<GetJsonBlobVoidFn>(); final GetProfiles = getProfilesC.asFunction<GetJsonBlobVoidFn>();
@ -201,8 +176,7 @@ class CwtchFfi implements Cwtch {
} }
Future<String> GetContacts(String onion) async { Future<String> GetContacts(String onion) async {
var getContactsC = library var getContactsC = library.lookup<NativeFunction<get_json_blob_string_function>>("c_GetContacts");
.lookup<NativeFunction<get_json_blob_string_function>>("c_GetContacts");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final GetContacts = getContactsC.asFunction<GetJsonBlobStringFn>(); final GetContacts = getContactsC.asFunction<GetJsonBlobStringFn>();
final utf8onion = onion.toNativeUtf8(); final utf8onion = onion.toNativeUtf8();
@ -212,52 +186,40 @@ class CwtchFfi implements Cwtch {
} }
Future<int> NumMessages(String profile, String handle) async { Future<int> NumMessages(String profile, String handle) async {
var numMessagesC = library var numMessagesC = library.lookup<NativeFunction<get_int_from_str_str_function>>("c_NumMessages");
.lookup<NativeFunction<get_int_from_str_str_function>>("c_NumMessages");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final NumMessages = numMessagesC.asFunction<GetIntFromStrStrFn>(); final NumMessages = numMessagesC.asFunction<GetIntFromStrStrFn>();
final utf8profile = profile.toNativeUtf8(); final utf8profile = profile.toNativeUtf8();
final utf8handle = handle.toNativeUtf8(); final utf8handle = handle.toNativeUtf8();
int num = NumMessages( int num = NumMessages(utf8profile, utf8profile.length, utf8handle, utf8handle.length);
utf8profile, utf8profile.length, utf8handle, utf8handle.length);
return num; return num;
} }
Future<String> GetMessage(String profile, String handle, int index) async { Future<String> GetMessage(String profile, String handle, int index) async {
var getMessageC = var getMessageC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_function>>("c_GetMessage");
library.lookup<NativeFunction<get_json_blob_from_str_str_int_function>>(
"c_GetMessage");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrStrIntFn>(); final GetMessage = getMessageC.asFunction<GetJsonBlobFromStrStrIntFn>();
final utf8profile = profile.toNativeUtf8(); final utf8profile = profile.toNativeUtf8();
final utf8handle = handle.toNativeUtf8(); final utf8handle = handle.toNativeUtf8();
Pointer<Utf8> jsonMessageBytes = GetMessage( Pointer<Utf8> jsonMessageBytes = GetMessage(utf8profile, utf8profile.length, utf8handle, utf8handle.length, index);
utf8profile, utf8profile.length, utf8handle, utf8handle.length, index);
String jsonMessage = jsonMessageBytes.toDartString(); String jsonMessage = jsonMessageBytes.toDartString();
return jsonMessage; return jsonMessage;
} }
Future<String> GetMessages( Future<String> GetMessages(String profile, String handle, int start, int end) async {
String profile, String handle, int start, int end) async { var getMessagesC = library.lookup<NativeFunction<get_json_blob_from_str_str_int_int_function>>("c_GetMessages");
var getMessagesC = library
.lookup<NativeFunction<get_json_blob_from_str_str_int_int_function>>(
"c_GetMessages");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final GetMessages = final GetMessages = getMessagesC.asFunction<GetJsonBlobFromStrStrIntIntFn>();
getMessagesC.asFunction<GetJsonBlobFromStrStrIntIntFn>();
final utf8profile = profile.toNativeUtf8(); final utf8profile = profile.toNativeUtf8();
final utf8handle = handle.toNativeUtf8(); final utf8handle = handle.toNativeUtf8();
Pointer<Utf8> jsonMessagesBytes = GetMessages(utf8profile, Pointer<Utf8> jsonMessagesBytes = GetMessages(utf8profile, utf8profile.length, utf8handle, utf8handle.length, start, end);
utf8profile.length, utf8handle, utf8handle.length, start, end);
String jsonMessages = jsonMessagesBytes.toDartString(); String jsonMessages = jsonMessagesBytes.toDartString();
return jsonMessages; return jsonMessages;
} }
@override @override
void SendProfileEvent(String onion, String json) { void SendProfileEvent(String onion, String json) {
var sendAppBusEvent = var sendAppBusEvent = library.lookup<NativeFunction<string_string_to_void_function>>("c_SendProfileEvent");
library.lookup<NativeFunction<string_string_to_void_function>>(
"c_SendProfileEvent");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final SendAppBusEvent = sendAppBusEvent.asFunction<StringStringFn>(); final SendAppBusEvent = sendAppBusEvent.asFunction<StringStringFn>();
final utf8onion = onion.toNativeUtf8(); final utf8onion = onion.toNativeUtf8();
@ -267,8 +229,7 @@ class CwtchFfi implements Cwtch {
@override @override
void SendAppEvent(String json) { void SendAppEvent(String json) {
var sendAppBusEvent = library var sendAppBusEvent = library.lookup<NativeFunction<string_to_void_function>>("c_SendAppEvent");
.lookup<NativeFunction<string_to_void_function>>("c_SendAppEvent");
// ignore: non_constant_identifier_names // ignore: non_constant_identifier_names
final SendAppBusEvent = sendAppBusEvent.asFunction<StringFn>(); final SendAppBusEvent = sendAppBusEvent.asFunction<StringFn>();
final utf8json = json.toNativeUtf8(); final utf8json = json.toNativeUtf8();

View File

@ -22,8 +22,7 @@ Future startCwtch() async {
*/ */
class CwtchGomobile implements Cwtch { class CwtchGomobile implements Cwtch {
static const appInfoPlatform = static const appInfoPlatform = const MethodChannel('test.flutter.dev/applicationInfo');
const MethodChannel('test.flutter.dev/applicationInfo');
static const cwtchPlatform = const MethodChannel('cwtch'); static const cwtchPlatform = const MethodChannel('cwtch');
final appbusEventChannelName = 'test.flutter.dev/eventBus'; final appbusEventChannelName = 'test.flutter.dev/eventBus';
@ -48,8 +47,7 @@ class CwtchGomobile implements Cwtch {
var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/"); var cwtchDir = path.join((await androidHomeDirectory).path, ".cwtch/dev/");
String torPath = path.join(await androidLibraryDir, "libtor.so"); String torPath = path.join(await androidLibraryDir, "libtor.so");
print("gomobile.dart: Start invokeMethod Start($cwtchDir, $torPath)..."); print("gomobile.dart: Start invokeMethod Start($cwtchDir, $torPath)...");
cwtchPlatform cwtchPlatform.invokeMethod("Start", {"appDir": cwtchDir, "torPath": torPath});
.invokeMethod("Start", {"appDir": cwtchDir, "torPath": torPath});
} }
// Handle libcwtch-go events (received via kotlin) and dispatch to the cwtchNotifier // Handle libcwtch-go events (received via kotlin) and dispatch to the cwtchNotifier
@ -89,26 +87,21 @@ class CwtchGomobile implements Cwtch {
} }
Future<int> NumMessages(String profile, String handle) { Future<int> NumMessages(String profile, String handle) {
return cwtchPlatform return cwtchPlatform.invokeMethod("NumMessages", {"profile": profile, "contact": handle});
.invokeMethod("NumMessages", {"profile": profile, "contact": handle});
} }
Future<String> GetMessage(String profile, String handle, int index) { Future<String> GetMessage(String profile, String handle, int index) {
print("gomobile.dart GetMessage " + index.toString()); print("gomobile.dart GetMessage " + index.toString());
return cwtchPlatform.invokeMethod( return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "index": index});
"GetMessage", {"profile": profile, "contact": handle, "index": index});
} }
Future<String> GetMessages( Future<String> GetMessages(String profile, String handle, int start, int end) {
String profile, String handle, int start, int end) { return cwtchPlatform.invokeMethod("GetMessage", {"profile": profile, "contact": handle, "start": start, "end": end});
return cwtchPlatform.invokeMethod("GetMessage",
{"profile": profile, "contact": handle, "start": start, "end": end});
} }
@override @override
void SendProfileEvent(String onion, String jsonEvent) { void SendProfileEvent(String onion, String jsonEvent) {
cwtchPlatform.invokeMethod( cwtchPlatform.invokeMethod("SendProfileEvent", {"onion": onion, "jsonEvent": jsonEvent});
"SendProfileEvent", {"onion": onion, "jsonEvent": jsonEvent});
} }
@override @override

View File

@ -47,6 +47,8 @@
"dontSavePeerHistory": "Peer-Verlauf löschen", "dontSavePeerHistory": "Peer-Verlauf löschen",
"editProfile": "Profil bearbeiten", "editProfile": "Profil bearbeiten",
"editProfileTitle": "Profil bearbeiten", "editProfileTitle": "Profil bearbeiten",
"enableGroups": "",
"enterCurrentPasswordForDelete": "",
"enterProfilePassword": "Geben Sie ein Passwort ein, um Ihre Profile anzuzeigen", "enterProfilePassword": "Geben Sie ein Passwort ein, um Ihre Profile anzuzeigen",
"error0ProfilesLoadedForPassword": "0 Profile mit diesem Passwort geladen", "error0ProfilesLoadedForPassword": "0 Profile mit diesem Passwort geladen",
"experimentsEnabled": "Experimente aktiviert", "experimentsEnabled": "Experimente aktiviert",

View File

@ -47,9 +47,11 @@
"dontSavePeerHistory": "Delete Peer History", "dontSavePeerHistory": "Delete Peer History",
"editProfile": "Edit Profille", "editProfile": "Edit Profille",
"editProfileTitle": "Edit Profile", "editProfileTitle": "Edit Profile",
"enableGroups": "Enable Group Chat",
"enterCurrentPasswordForDelete": "Please enter current password to delete this profile.",
"enterProfilePassword": "Enter a password to view your profiles", "enterProfilePassword": "Enter a password to view your profiles",
"error0ProfilesLoadedForPassword": "0 profiles loaded with that password", "error0ProfilesLoadedForPassword": "0 profiles loaded with that password",
"experimentsEnabled": "Experiments enabled", "experimentsEnabled": "Enable Experiments",
"groupAddr": "Address", "groupAddr": "Address",
"groupName": "Group name", "groupName": "Group name",
"groupNameLabel": "Group Name", "groupNameLabel": "Group Name",

View File

@ -47,6 +47,8 @@
"dontSavePeerHistory": "Eliminar historial de contacto", "dontSavePeerHistory": "Eliminar historial de contacto",
"editProfile": "Editar perfil", "editProfile": "Editar perfil",
"editProfileTitle": "Editar perfil", "editProfileTitle": "Editar perfil",
"enableGroups": "",
"enterCurrentPasswordForDelete": "",
"enterProfilePassword": "Ingresa tu contraseña para ver tus perfiles", "enterProfilePassword": "Ingresa tu contraseña para ver tus perfiles",
"error0ProfilesLoadedForPassword": "0 perfiles cargados con esa contraseña", "error0ProfilesLoadedForPassword": "0 perfiles cargados con esa contraseña",
"experimentsEnabled": "Experimentos habilitados", "experimentsEnabled": "Experimentos habilitados",

View File

@ -47,6 +47,8 @@
"dontSavePeerHistory": "", "dontSavePeerHistory": "",
"editProfile": "", "editProfile": "",
"editProfileTitle": "", "editProfileTitle": "",
"enableGroups": "",
"enterCurrentPasswordForDelete": "",
"enterProfilePassword": "", "enterProfilePassword": "",
"error0ProfilesLoadedForPassword": "", "error0ProfilesLoadedForPassword": "",
"experimentsEnabled": "", "experimentsEnabled": "",

View File

@ -47,6 +47,8 @@
"dontSavePeerHistory": "Elimina cronologia dei peer", "dontSavePeerHistory": "Elimina cronologia dei peer",
"editProfile": "Modifica profilo", "editProfile": "Modifica profilo",
"editProfileTitle": "Modifica profilo", "editProfileTitle": "Modifica profilo",
"enableGroups": "",
"enterCurrentPasswordForDelete": "",
"enterProfilePassword": "Inserisci una password per visualizzare i tuoi profili", "enterProfilePassword": "Inserisci una password per visualizzare i tuoi profili",
"error0ProfilesLoadedForPassword": "0 profili caricati con quella password", "error0ProfilesLoadedForPassword": "0 profili caricati con quella password",
"experimentsEnabled": "Esperimenti abilitati", "experimentsEnabled": "Esperimenti abilitati",

View File

@ -47,6 +47,8 @@
"dontSavePeerHistory": "", "dontSavePeerHistory": "",
"editProfile": "", "editProfile": "",
"editProfileTitle": "", "editProfileTitle": "",
"enableGroups": "",
"enterCurrentPasswordForDelete": "",
"enterProfilePassword": "", "enterProfilePassword": "",
"error0ProfilesLoadedForPassword": "", "error0ProfilesLoadedForPassword": "",
"experimentsEnabled": "", "experimentsEnabled": "",

117
lib/licenses.dart Normal file
View File

@ -0,0 +1,117 @@
import 'package:flutter/foundation.dart';
Stream<LicenseEntry> licenses() async* {
/// Open Privacy Code
yield LicenseEntryWithLineBreaks(["cwtch", "tapir", "connectivity", "log"], '''MIT License
Copyright (c) 2018 Open Privacy Research Society
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files ("the Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.''');
/// Ristretto Code
yield LicenseEntryWithLineBreaks(["ristretto255"], '''Copyright (c) 2009 The Go Authors. All rights reserved.
Copyright (c) 2017 George Tankersley. All rights reserved.
Copyright (c) 2019 Henry de Valence. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''');
/// Package pretty provides pretty-printing for Go values. (via Cwtch)
yield LicenseEntryWithLineBreaks(["pretty"], '''Copyright 2012 Keith Rarick
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.''');
yield LicenseEntryWithLineBreaks(["pidusage"], '''MIT License
Copyright (c) 2017 David
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.''');
/// Go Standard Lib
yield LicenseEntryWithLineBreaks(["crypto, net"], '''Copyright (c) 2009 The Go Authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following disclaimer
in the documentation and/or other materials provided with the
distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.''');
}

View File

@ -1,3 +1,4 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_app/cwtch/ffi.dart'; import 'package:flutter_app/cwtch/ffi.dart';
import 'package:flutter_app/cwtch/gomobile.dart'; import 'package:flutter_app/cwtch/gomobile.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -6,6 +7,7 @@ import 'package:flutter_app/views/triplecolview.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'cwtch/cwtch.dart'; import 'cwtch/cwtch.dart';
import 'cwtch/cwtchNotifier.dart'; import 'cwtch/cwtchNotifier.dart';
import 'licenses.dart';
import 'model.dart'; import 'model.dart';
import 'views/profilemgrview.dart'; import 'views/profilemgrview.dart';
import 'views/splashView.dart'; import 'views/splashView.dart';
@ -13,9 +15,12 @@ import 'dart:io' show Platform;
import 'opaque.dart'; import 'opaque.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart';
var GlobalSettings = Settings(Locale("en", ''), Opaque.dark); var globalSettings = Settings(Locale("en", ''), Opaque.dark);
void main() => runApp(Flwtch()); void main() {
LicenseRegistry.addLicense(() => licenses());
runApp(Flwtch());
}
class Flwtch extends StatefulWidget { class Flwtch extends StatefulWidget {
final Key flwtch = GlobalKey(); final Key flwtch = GlobalKey();
@ -41,7 +46,7 @@ class FlwtchState extends State<Flwtch> {
cwtchInit = false; cwtchInit = false;
profs = ProfileListState(); profs = ProfileListState();
var cwtchNotifier = new CwtchNotifier(profs, GlobalSettings); var cwtchNotifier = new CwtchNotifier(profs, globalSettings);
if (Platform.isAndroid) { if (Platform.isAndroid) {
cwtch = CwtchGomobile(cwtchNotifier); cwtch = CwtchGomobile(cwtchNotifier);
@ -58,23 +63,16 @@ class FlwtchState extends State<Flwtch> {
appStatus = AppModel(cwtch: cwtch); appStatus = AppModel(cwtch: cwtch);
} }
ChangeNotifierProvider<Settings> getSettingsProvider() => ChangeNotifierProvider<Settings> getSettingsProvider() => ChangeNotifierProvider(create: (context) => globalSettings);
ChangeNotifierProvider(create: (context) => GlobalSettings); Provider<FlwtchState> getFlwtchStateProvider() => Provider<FlwtchState>(create: (_) => this);
Provider<FlwtchState> getFlwtchStateProvider() => ChangeNotifierProvider<ProfileListState> getProfileListProvider() => ChangeNotifierProvider(create: (context) => profs);
Provider<FlwtchState>(create: (_) => this);
ChangeNotifierProvider<ProfileListState> getProfileListProvider() =>
ChangeNotifierProvider(create: (context) => profs);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
appStatus = AppModel(cwtch: cwtch); appStatus = AppModel(cwtch: cwtch);
return MultiProvider( return MultiProvider(
providers: [ providers: [getFlwtchStateProvider(), getProfileListProvider(), getSettingsProvider()],
getFlwtchStateProvider(),
getProfileListProvider(),
getSettingsProvider()
],
builder: (context, widget) { builder: (context, widget) {
Provider.of<Settings>(context).initPackageInfo(); Provider.of<Settings>(context).initPackageInfo();
return Consumer<Settings>( return Consumer<Settings>(
@ -97,20 +95,15 @@ class FlwtchState extends State<Flwtch> {
cardColor: opaque.current().backgroundMainColor(), cardColor: opaque.current().backgroundMainColor(),
textButtonTheme: TextButtonThemeData( textButtonTheme: TextButtonThemeData(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all( backgroundColor: MaterialStateProperty.all(opaque.current().defaultButtonColor()),
opaque.current().defaultButtonColor()), foregroundColor: MaterialStateProperty.all(opaque.current().defaultButtonTextColor()),
foregroundColor: MaterialStateProperty.all( overlayColor: MaterialStateProperty.all(opaque.current().defaultButtonActiveColor()),
opaque.current().defaultButtonTextColor()),
overlayColor: MaterialStateProperty.all(
opaque.current().defaultButtonActiveColor()),
padding: MaterialStateProperty.all(EdgeInsets.all(20))), padding: MaterialStateProperty.all(EdgeInsets.all(20))),
), ),
dialogTheme: DialogTheme( dialogTheme: DialogTheme(
backgroundColor: opaque.current().backgroundPaneColor(), backgroundColor: opaque.current().backgroundPaneColor(),
titleTextStyle: titleTextStyle: TextStyle(color: opaque.current().mainTextColor()),
TextStyle(color: opaque.current().mainTextColor()), contentTextStyle: TextStyle(color: opaque.current().mainTextColor())),
contentTextStyle:
TextStyle(color: opaque.current().mainTextColor())),
textTheme: TextTheme( textTheme: TextTheme(
headline1: TextStyle(color: opaque.current().mainTextColor()), headline1: TextStyle(color: opaque.current().mainTextColor()),
headline2: TextStyle(color: opaque.current().mainTextColor()), headline2: TextStyle(color: opaque.current().mainTextColor()),
@ -128,9 +121,7 @@ class FlwtchState extends State<Flwtch> {
), ),
// from dan: home: cwtchInit == true ? ProfileMgrView(cwtch) : SplashView(), // from dan: home: cwtchInit == true ? ProfileMgrView(cwtch) : SplashView(),
// from erinn: home: columns.length == 3 ? TripleColumnView() : ProfileMgrView(), // from erinn: home: columns.length == 3 ? TripleColumnView() : ProfileMgrView(),
home: cwtchInit == true home: cwtchInit == true ? (columns.length == 3 ? TripleColumnView() : ProfileMgrView()) : SplashView(),
? (columns.length == 3 ? TripleColumnView() : ProfileMgrView())
: SplashView(),
), ),
); );
}, },

View File

@ -29,13 +29,7 @@ class ContactModel {
String status; String status;
String imagePath; String imagePath;
ContactModel( ContactModel({this.onion, this.nickname, this.status, this.isInvitation, this.isBlocked, this.imagePath});
{this.onion,
this.nickname,
this.status,
this.isInvitation,
this.isBlocked,
this.imagePath});
} }
//todo: delete //todo: delete
@ -78,12 +72,12 @@ class ProfileListState extends ChangeNotifier {
} }
void add(ProfileInfoState newProfile) { void add(ProfileInfoState newProfile) {
print("ProfileListState: adding " + newProfile.onion +" and notifying"); print("ProfileListState: adding " + newProfile.onion + " and notifying");
_profiles.add(newProfile); _profiles.add(newProfile);
notifyListeners(); notifyListeners();
} }
List<ProfileInfoState> get profiles => _profiles.sublist(0);//todo: copy?? dont want caller able to bypass changenotifier List<ProfileInfoState> get profiles => _profiles.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
ProfileInfoState getProfile(String onion) { ProfileInfoState getProfile(String onion) {
int idx = _profiles.indexWhere((element) => element.onion == onion); int idx = _profiles.indexWhere((element) => element.onion == onion);
@ -106,13 +100,15 @@ class ContactListState extends ChangeNotifier {
} }
void updateUnreadMessages(String forOnion, int newVal) { void updateUnreadMessages(String forOnion, int newVal) {
_contacts.sort((ContactInfoState a, ContactInfoState b) { return b.unreadMessages - a.unreadMessages; }); _contacts.sort((ContactInfoState a, ContactInfoState b) {
return b.unreadMessages - a.unreadMessages;
});
//<todo> if(changed) { //<todo> if(changed) {
notifyListeners(); notifyListeners();
//} </todo> //} </todo>
} }
List<ContactInfoState> get contacts => _contacts.sublist(0);//todo: copy?? dont want caller able to bypass changenotifier List<ContactInfoState> get contacts => _contacts.sublist(0); //todo: copy?? dont want caller able to bypass changenotifier
ContactInfoState getContact(String onion) { ContactInfoState getContact(String onion) {
int idx = _contacts.indexWhere((element) => element.onion == onion); int idx = _contacts.indexWhere((element) => element.onion == onion);
@ -127,7 +123,13 @@ class ProfileInfoState extends ChangeNotifier {
String _imagePath = ""; String _imagePath = "";
int _unreadMessages = 0; int _unreadMessages = 0;
ProfileInfoState({this.onion, nickname = "", imagePath = "", unreadMessages = 0, contactsJson = "",}){ ProfileInfoState({
this.onion,
nickname = "",
imagePath = "",
unreadMessages = 0,
contactsJson = "",
}) {
this._nickname = nickname; this._nickname = nickname;
this._imagePath = imagePath; this._imagePath = imagePath;
this._unreadMessages = unreadMessages; this._unreadMessages = unreadMessages;
@ -135,17 +137,15 @@ class ProfileInfoState extends ChangeNotifier {
if (contactsJson != null && contactsJson != "" && contactsJson != "null") { if (contactsJson != null && contactsJson != "" && contactsJson != "null") {
print("decoding " + contactsJson); print("decoding " + contactsJson);
List<dynamic> contacts = jsonDecode(contactsJson); List<dynamic> contacts = jsonDecode(contactsJson);
this._contacts.addAll( this._contacts.addAll(contacts.map((contact) {
contacts.map((contact){ return ContactInfoState(
return ContactInfoState( profileOnion: this.onion,
profileOnion: this.onion, onion: contact["onion"],
onion: contact["onion"], nickname: contact["name"],
nickname: contact["name"], status: contact["status"],
status: contact["status"], imagePath: contact["picture"],
imagePath: contact["picture"], );
); }));
})
);
} }
} }

View File

@ -1,509 +0,0 @@
// THIS FILE IS AUTOMATICALLY GENERATED. DO NOT EDIT BY HAND AS CHANGES WILL BE OVERRIDDEN.
// TO EDIT THE THEME, SEE https://git.openprivacy.ca/openprivacy/opaque/
// FOR HOW THIS FILE IS GENERATED, SEE ../regenerate_opaque_theme.sh
import 'dart:ui';
import 'dart:core';
abstract class OpaqueThemeType {
static final Color red = Color(0xFFFF0000);
Color backgroundMainColor(){return red;}
Color backgroundPaneColor(){return red;}
Color backgroundHilightElementColor(){return red;}
Color dividerColor(){return red;}
Color mainTextColor(){return red;}
Color altTextColor(){return red;}
Color hilightElementTextColor(){return red;}
Color defaultButtonColor(){return red;}
Color defaultButtonActiveColor(){return red;}
Color defaultButtonTextColor(){return red;}
Color defaultButtonDisabledColor(){return red;}
Color defaultButtonDisabledTextColor(){return red;}
Color altButtonColor(){return red;}
Color altButtonTextColor(){return red;}
Color altButtonDisabledColor(){return red;}
Color altButtonDisabledTextColor(){return red;}
Color textfieldBackgroundColor(){return red;}
Color textfieldBorderColor(){return red;}
Color textfieldTextColor(){return red;}
Color textfieldErrorColor(){return red;}
Color textfieldButtonColor(){return red;}
Color textfieldButtonTextColor(){return red;}
Color scrollbarDefaultColor(){return red;}
Color scrollbarActiveColor(){return red;}
Color portraitOnlineBorderColor(){return red;}
Color portraitOnlineBackgroundColor(){return red;}
Color portraitOnlineTextColor(){return red;}
Color portraitConnectingBorderColor(){return red;}
Color portraitConnectingBackgroundColor(){return red;}
Color portraitConnectingTextColor(){return red;}
Color portraitOfflineBorderColor(){return red;}
Color portraitOfflineBackgroundColor(){return red;}
Color portraitOfflineTextColor(){return red;}
Color portraitBlockedBorderColor(){return red;}
Color portraitBlockedBackgroundColor(){return red;}
Color portraitBlockedTextColor(){return red;}
Color portraitOnlineBadgeColor(){return red;}
Color portraitOfflineBadgeColor(){return red;}
Color portraitContactBadgeColor(){return red;}
Color portraitContactBadgeTextColor(){return red;}
Color portraitProfileBadgeColor(){return red;}
Color portraitProfileBadgeTextColor(){return red;}
Color portraitOverlayOfflineColor(){return red;}
Color dropShadowColor(){return red;}
Color dropShadowPaneColor(){return red;}
Color toggleColor(){return red;}
Color toggleOnColor(){return red;}
Color toggleOffColor(){return red;}
Color sliderButtonColor(){return red;}
Color sliderBarLeftColor(){return red;}
Color sliderBarRightColor(){return red;}
Color boxCheckedColor(){return red;}
Color toolbarIconColor(){return red;}
Color toolbarMainColor(){return red;}
Color toolbarAltColor(){return red;}
Color statusbarDisconnectedInternetColor(){return red;}
Color statusbarDisconnectedInternetFontColor(){return red;}
Color statusbarDisconnectedTorFontColor(){return red;}
Color statusbarDisconnectedTorColor(){return red;}
Color statusbarConnectingColor(){return red;}
Color statusbarConnectingFontColor(){return red;}
Color statusbarOnlineColor(){return red;}
Color statusbarOnlineFontColor(){return red;}
Color chatOverlayWarningTextColor(){return red;}
Color messageFromMeBackgroundColor(){return red;}
Color messageFromMeTextColor(){return red;}
Color messageFromOtherBackgroundColor(){return red;}
Color messageFromOtherTextColor(){return red;}
Color messageStatusNormalColor(){return red;}
Color messageStatusBlockedColor(){return red;}
Color messageStatusBlockedTextColor(){return red;}
Color messageStatusAlertColor(){return red;}
Color messageStatusAlertTextColor(){return red;}
// ... more to come
}
class CwtchDark extends OpaqueThemeType {
static final Color darkGreyPurple = Color(0xFF281831);
static final Color deepPurple = Color(0xFF422850);
static final Color mauvePurple = Color(0xFF8E64A5);
static final Color purple = Color(0xFFDFB9DE);
static final Color whitePurple = Color(0xFFE3DFE4);
static final Color softPurple = Color(0xFFFDF3FC);
static final Color pink = Color(0xFFE85DA1);
static final Color hotPink = Color(0xFFD01972);
static final Color lightGrey = Color(0xFF9E9E9E);
static final Color softGreen = Color(0xFFA0FFB0);
static final Color softRed = Color(0xFFFFA0B0);
Color backgroundMainColor() { return darkGreyPurple; }
Color backgroundPaneColor() { return darkGreyPurple; }
Color backgroundHilightElementColor() { return deepPurple; }
Color dividerColor() { return deepPurple; }
Color mainTextColor() { return whitePurple; }
Color altTextColor() { return whitePurple; }
Color hilightElementTextColor() { return purple; }
Color defaultButtonColor() { return hotPink; }
Color defaultButtonActiveColor() { return pink; }
Color defaultButtonTextColor() { return whitePurple; }
Color defaultButtonDisabledColor() { return deepPurple; }
Color defaultButtonDisabledTextColor() { return darkGreyPurple; }
Color altButtonColor() { return darkGreyPurple; }
Color altButtonTextColor() { return purple; }
Color altButtonDisabledColor() { return darkGreyPurple; }
Color altButtonDisabledTextColor() { return purple; }
Color textfieldBackgroundColor() { return deepPurple; }
Color textfieldBorderColor() { return deepPurple; }
Color textfieldTextColor() { return purple; }
Color textfieldErrorColor() { return hotPink; }
Color textfieldButtonColor() { return purple; }
Color textfieldButtonTextColor() { return darkGreyPurple; }
Color scrollbarDefaultColor() { return purple; }
Color scrollbarActiveColor() { return hotPink; }
Color portraitOnlineBorderColor() { return whitePurple; }
Color portraitOnlineBackgroundColor() { return whitePurple; }
Color portraitOnlineTextColor() { return whitePurple; }
Color portraitConnectingBorderColor() { return purple; } //mauvePurple
Color portraitConnectingBackgroundColor() { return purple; } //darkGreyPurple
Color portraitConnectingTextColor() { return purple; }
Color portraitOfflineBorderColor() { return purple; }
Color portraitOfflineBackgroundColor() { return purple; }
Color portraitOfflineTextColor() { return purple; }
Color portraitBlockedBorderColor() { return lightGrey; }
Color portraitBlockedBackgroundColor() { return lightGrey; }
Color portraitBlockedTextColor() { return lightGrey; }
Color portraitOnlineBadgeColor() { return softGreen; }
Color portraitOfflineBadgeColor() { return softRed; }
Color portraitContactBadgeColor() { return hotPink; }
Color portraitContactBadgeTextColor() { return whitePurple; }
Color portraitProfileBadgeColor() { return mauvePurple; }
Color portraitProfileBadgeTextColor() { return darkGreyPurple; }
Color portraitOverlayOfflineColor() { return mauvePurple; }
Color dropShadowColor() { return mauvePurple; }
Color dropShadowPaneColor() { return darkGreyPurple; }
Color toggleColor() { return darkGreyPurple; }
Color toggleOnColor() { return whitePurple; }
Color toggleOffColor() { return deepPurple; }
Color sliderButtonColor() { return whitePurple; }
Color sliderBarLeftColor() { return mauvePurple; }
Color sliderBarRightColor() { return mauvePurple; }
Color boxCheckedColor() { return hotPink; }
Color toolbarIconColor() { return whitePurple; }
Color toolbarMainColor() { return darkGreyPurple; }
Color toolbarAltColor() { return deepPurple; }
Color statusbarDisconnectedInternetColor() { return whitePurple; }
Color statusbarDisconnectedInternetFontColor() { return deepPurple; }
Color statusbarDisconnectedTorColor() { return darkGreyPurple; }
Color statusbarDisconnectedTorFontColor() { return whitePurple; }
Color statusbarConnectingColor() { return deepPurple; }
Color statusbarConnectingFontColor() { return whitePurple; }
Color statusbarOnlineColor() { return mauvePurple; }
Color statusbarOnlineFontColor() { return whitePurple; }
Color chatOverlayWarningTextColor() { return purple; }
Color messageFromMeBackgroundColor() { return mauvePurple; }
Color messageFromMeTextColor() { return whitePurple; }
Color messageFromOtherBackgroundColor() { return deepPurple; }
Color messageFromOtherTextColor() { return whitePurple; }
Color messageStatusNormalColor() { return deepPurple; }
Color messageStatusBlockedColor() { return lightGrey; }
Color messageStatusBlockedTextColor() { return whitePurple; }
Color messageStatusAlertColor() { return mauvePurple; }
Color messageStatusAlertTextColor() { return whitePurple; }
}
class CwtchLight extends OpaqueThemeType {
static final Color whitePurple = Color(0xFFFFFDFF);
static final Color softPurple = Color(0xFFFDF3FC);
static final Color purple = Color(0xFFDFB9DE);
static final Color brightPurple = Color(0xFF760388);
static final Color darkPurple = Color(0xFF350052);
static final Color greyPurple = Color(0xFF775F84);
static final Color pink = Color(0xFFE85DA1);
static final Color hotPink = Color(0xFFD01972);
static final Color lightGrey = Color(0xFFB3B6B3);
static final Color softGreen = Color(0xFFA0FFB0);
static final Color softRed = Color(0xFFFFA0B0);
Color backgroundMainColor() { return whitePurple; }
Color backgroundPaneColor() { return softPurple; }
Color backgroundHilightElementColor() { return softPurple; }
Color dividerColor() { return purple; }
Color mainTextColor() { return darkPurple; }
Color altTextColor() { return purple; }
Color hilightElementTextColor() { return darkPurple; }
Color defaultButtonColor() { return hotPink; }
Color defaultButtonActiveColor() { return pink; }
Color defaultButtonTextColor() { return whitePurple; }
Color defaultButtonDisabledColor() { return purple; }
Color defaultButtonDisabledTextColor() { return whitePurple; }
Color altButtonColor() { return whitePurple; }
Color altButtonTextColor() { return purple; }
Color altButtonDisabledColor() { return softPurple; }
Color altButtonDisabledTextColor() { return purple; }
Color textfieldBackgroundColor() { return whitePurple; }
Color textfieldBorderColor() { return purple; }
Color textfieldTextColor() { return purple; }
Color textfieldErrorColor() { return hotPink; }
Color textfieldButtonColor() { return hotPink; }
Color textfieldButtonTextColor() { return whitePurple; }
Color scrollbarDefaultColor() { return darkPurple; }
Color scrollbarActiveColor() { return hotPink; }
Color portraitOnlineBorderColor() { return darkPurple; }
Color portraitOnlineBackgroundColor() { return darkPurple; }
Color portraitOnlineTextColor() { return darkPurple; }
Color portraitConnectingBorderColor() { return greyPurple; }
Color portraitConnectingBackgroundColor() { return greyPurple; }
Color portraitConnectingTextColor() { return greyPurple; }
Color portraitOfflineBorderColor() { return greyPurple; } //purple
Color portraitOfflineBackgroundColor() { return greyPurple; } //purple
Color portraitOfflineTextColor() { return greyPurple; }//purple
Color portraitBlockedBorderColor() { return lightGrey; }
Color portraitBlockedBackgroundColor() { return lightGrey; }
Color portraitBlockedTextColor() { return lightGrey; }
Color portraitOnlineBadgeColor() { return softGreen; }
Color portraitOfflineBadgeColor() { return softRed; }
Color portraitContactBadgeColor() { return hotPink; }
Color portraitContactBadgeTextColor() { return whitePurple; }
Color portraitProfileBadgeColor() { return brightPurple; }
Color portraitProfileBadgeTextColor() { return whitePurple; }
Color portraitOverlayOfflineColor() { return whitePurple; }
Color dropShadowColor() { return purple; }
Color dropShadowPaneColor() { return purple; }
Color toggleColor() { return whitePurple; }
Color toggleOnColor() { return hotPink; }
Color toggleOffColor() { return purple; }
Color sliderButtonColor() { return pink; }
Color sliderBarLeftColor() { return purple; }
Color sliderBarRightColor() { return purple; }
Color boxCheckedColor() { return darkPurple; }
Color toolbarIconColor() { return darkPurple; }
Color toolbarMainColor() { return whitePurple; }
Color toolbarAltColor() { return softPurple; }
Color statusbarDisconnectedInternetColor() { return softPurple; }
Color statusbarDisconnectedInternetFontColor() { return darkPurple; }
Color statusbarDisconnectedTorColor() { return purple; }
Color statusbarDisconnectedTorFontColor() { return darkPurple; }
Color statusbarConnectingColor() { return greyPurple; }
Color statusbarConnectingFontColor() { return whitePurple; }
Color statusbarOnlineColor() { return darkPurple; }
Color statusbarOnlineFontColor() { return whitePurple; }
Color chatOverlayWarningTextColor() { return purple; }
Color messageFromMeBackgroundColor() { return darkPurple; }
Color messageFromMeTextColor() { return whitePurple; }
Color messageFromOtherBackgroundColor() { return purple; }
Color messageFromOtherTextColor() { return darkPurple; }
Color messageStatusNormalColor() { return purple; }
Color messageStatusBlockedColor() { return lightGrey; }
Color messageStatusBlockedTextColor() { return whitePurple; }
Color messageStatusAlertColor() { return hotPink; }
Color messageStatusAlertTextColor() { return whitePurple; }
}
class Opaque extends OpaqueThemeType {
Color backgroundMainColor() { return current().backgroundMainColor(); }
Color backgroundPaneColor() { return current().backgroundPaneColor(); }
Color backgroundHilightElementColor() { return current().backgroundHilightElementColor(); }
Color dividerColor() { return current().dividerColor(); }
Color mainTextColor() { return current().mainTextColor(); }
Color altTextColor() { return current().altTextColor(); }
Color hilightElementTextColor() { return current().hilightElementTextColor(); }
Color defaultButtonColor() { return current().defaultButtonColor(); }
Color defaultButtonActiveColor() { return current().defaultButtonActiveColor(); }
Color defaultButtonTextColor() { return current().defaultButtonTextColor(); }
Color defaultButtonDisabledColor() { return current().defaultButtonDisabledColor(); }
Color defaultButtonDisabledTextColor() { return current().defaultButtonDisabledTextColor(); }
Color altButtonColor() { return current().altButtonColor(); }
Color altButtonTextColor() { return current().altButtonTextColor(); }
Color altButtonDisabledColor() { return current().altButtonDisabledColor(); }
Color altButtonDisabledTextColor() { return current().altButtonDisabledTextColor(); }
Color textfieldBackgroundColor() { return current().textfieldBackgroundColor(); }
Color textfieldBorderColor() { return current().textfieldBorderColor(); }
Color textfieldTextColor() { return current().textfieldTextColor(); }
Color textfieldErrorColor() { return current().textfieldErrorColor(); }
Color textfieldButtonColor() { return current().textfieldButtonColor(); }
Color textfieldButtonTextColor() { return current().textfieldButtonTextColor(); }
Color dropShadowColor() { return current().dropShadowColor(); }
Color dropShadowPaneColor() { return current().dropShadowPaneColor(); }
Color portraitOnlineBorderColor() { return current().portraitOnlineBorderColor(); }
Color portraitOnlineBackgroundColor() { return current().portraitOnlineBackgroundColor(); }
Color portraitOnlineTextColor() { return current().portraitOnlineTextColor(); }
Color portraitConnectingBorderColor() { return current().portraitConnectingBorderColor(); }
Color portraitConnectingBackgroundColor() { return current().portraitConnectingBackgroundColor(); }
Color portraitConnectingTextColor() { return current().portraitConnectingTextColor(); }
Color portraitOfflineBorderColor() { return current().portraitOfflineBorderColor(); }
Color portraitOfflineBackgroundColor() { return current().portraitOfflineBackgroundColor(); }
Color portraitOfflineTextColor() { return current().portraitOfflineTextColor(); }
Color portraitBlockedBorderColor() { return current().portraitBlockedBorderColor(); }
Color portraitBlockedBackgroundColor() { return current().portraitBlockedBackgroundColor(); }
Color portraitBlockedTextColor() { return current().portraitBlockedTextColor(); }
Color portraitOnlineBadgeColor() { return current().portraitOnlineBadgeColor(); }
Color portraitOfflineBadgeColor() { return current().portraitOfflineBadgeColor(); }
Color portraitContactBadgeColor() { return current().portraitContactBadgeColor(); }
Color portraitContactBadgeTextColor() { return current().portraitContactBadgeTextColor(); }
Color portraitProfileBadgeColor() { return current().portraitProfileBadgeColor(); }
Color portraitProfileBadgeTextColor() { return current().portraitProfileBadgeTextColor(); }
Color portraitOverlayOfflineColor() { return current().portraitOverlayOfflineColor(); }
Color toggleColor() { return current().toggleColor(); }
Color toggleOffColor() { return current().toggleOffColor(); }
Color toggleOnColor() { return current().toggleOnColor(); }
Color sliderButtonColor() { return current().sliderButtonColor(); }
Color sliderBarLeftColor() { return current().sliderBarLeftColor(); }
Color sliderBarRightColor() { return current().sliderBarRightColor(); }
Color boxCheckedColor() { return current().boxCheckedColor(); }
Color toolbarIconColor() { return current().toolbarIconColor(); }
Color toolbarMainColor() { return current().toolbarMainColor(); }
Color toolbarAltColor() { return current().toolbarAltColor(); }
Color statusbarDisconnectedInternetColor() { return current().statusbarDisconnectedInternetColor(); }
Color statusbarDisconnectedInternetFontColor() { return current().statusbarDisconnectedInternetFontColor(); }
Color statusbarDisconnectedTorFontColor() { return current().statusbarDisconnectedTorFontColor(); }
Color statusbarDisconnectedTorColor() { return current().statusbarDisconnectedTorColor(); }
Color statusbarConnectingColor() { return current().statusbarConnectingColor(); }
Color statusbarConnectingFontColor() { return current().statusbarConnectingFontColor(); }
Color statusbarOnlineColor() { return current().statusbarOnlineColor(); }
Color statusbarOnlineFontColor() { return current().statusbarOnlineFontColor(); }
Color chatOverlayWarningTextColor() { return current().chatOverlayWarningTextColor(); }
Color messageFromMeBackgroundColor() { return current().messageFromMeBackgroundColor(); }
Color messageFromMeTextColor() { return current().messageFromMeTextColor(); }
Color messageFromOtherBackgroundColor() { return current().messageFromOtherBackgroundColor(); }
Color messageFromOtherTextColor() { return current().messageFromOtherTextColor(); }
Color messageStatusNormalColor() { return current().messageStatusNormalColor(); }
Color messageStatusBlockedColor() { return current().messageStatusBlockedColor(); }
Color messageStatusBlockedTextColor() { return current().messageStatusBlockedTextColor(); }
Color messageStatusAlertColor() { return current().messageStatusAlertColor(); }
Color messageStatusAlertTextColor() { return current().messageStatusAlertTextColor(); }
Color scrollbarDefaultColor() { return current().scrollbarDefaultColor(); }
Color scrollbarActiveColor() { return current().scrollbarActiveColor(); }
var sidePaneMinSizeBase = [200, 400, 600];
int sidePaneMinSize() { return sidePaneMinSizeBase[p[scale]]+200/*for debugging*/; }
var chatPaneMinSizeBase = [300, 400, 500];
int chatPaneMinSize() { return chatPaneMinSizeBase[p[scale]]; }
int doublePaneMinSize() { return sidePaneMinSize() + chatPaneMinSize(); }
static final OpaqueThemeType dark = CwtchDark();
static final OpaqueThemeType light = CwtchLight();
static static Opaque current() { return dark; }
int scale = 2;
static final String gcdOS = "linux";
var p = [0, 1, 1, 1, 2];
var t = [0, 0, 1, 2, 2];
var paddingMinimalBase = [1, 4, 6];
int paddingMinimal() { return paddingMinimalBase[p[scale]]; }
var paddingSmallBase = [3, 10, 15];
int paddingSmall() { return paddingSmallBase[p[scale]]; }
var paddingStandardBase = [8, 20, 30];
int paddingStandard() { return paddingStandardBase[p[scale]]; }
var paddingLargeBase = [10, 30, 40];
int paddingLarge() { return paddingLargeBase[p[scale]]; }
var paddingClickTargetBase = gcdOS == "android" ? [10, 40, 100] : [3, 10, 15];
int paddingClickTarget() { return paddingClickTargetBase[p[scale]]; }
var textSmallPtBase = [8, 12, 16];
int textSmallPt() { return textSmallPtBase[t[scale]]; }
var textMediumPtBase = [10, 16, 24];
int textMediumPt() { return textMediumPtBase[t[scale]]; }
var textLargePtBase = [16, 24, 32];
int textLargePt() { return textLargePtBase[t[scale]]; }
var textSubHeaderPtBase = [12, 18, 26];
int textSubHeaderPt() { return textHeaderPtBase[t[scale]]; }
var textHeaderPtBase = [16, 24, 32];
int textHeaderPt() { return textHeaderPtBase[t[scale]]; }
var uiIconSizeSBase = [8, 16, 24];
int uiIconSizeS() { return uiIconSizeSBase[p[scale]]; }
var uiIconSizeMBase = [24, 32, 48];
int uiIconSizeM() { return uiIconSizeMBase[p[scale]]; }
var uiIconSizeLBase = [32, 48, 60];
int uiIconSizeL() { return uiIconSizeLBase[p[scale]]; }
var uiEmojiSizeBase = [24, 32, 48];
int uiEmojiSize() { return uiEmojiSizeBase[p[scale]]; }
var contactPortraitSizeBase = [60, 72, 84];
int contactPortraitSize() { return contactPortraitSizeBase[p[scale]]; }
int badgeTextSize() { return 12; }
int statusTextSize() { return 12; }
int chatSize() { return textMediumPt(); }
int tabSize() { return textMediumPt(); }
}

View File

@ -1,3 +1,4 @@
import 'dart:collection';
import 'dart:ui'; import 'dart:ui';
import 'dart:core'; import 'dart:core';
@ -6,38 +7,57 @@ import 'package:package_info_plus/package_info_plus.dart';
import 'opaque.dart'; import 'opaque.dart';
/// Settings govern the *Globally* relevant settings like Locale, Theme and Experiments.
/// We also provide access to the version information here as it is also accessed from the
/// Settings Pane.
class Settings extends ChangeNotifier { class Settings extends ChangeNotifier {
Locale locale; Locale locale;
PackageInfo packageInfo; PackageInfo packageInfo;
OpaqueThemeType theme; OpaqueThemeType theme;
bool experimentsEnabled;
HashMap<String, bool> experiments = HashMap.identity();
/// Set the dark theme.
void setDark() { void setDark() {
theme = Opaque.dark; theme = Opaque.dark;
notifyListeners(); notifyListeners();
} }
/// Set the Light theme.
void setLight() { void setLight() {
theme = Opaque.light; theme = Opaque.light;
notifyListeners(); notifyListeners();
} }
/// Get access to the current theme.
OpaqueThemeType current() { OpaqueThemeType current() {
return theme; return theme;
} }
/// Called by the event bus. When new settings are loaded from a file the JSON will
/// be sent to the function and new settings will be instantiated based on the contents.
handleUpdate(dynamic settings) { handleUpdate(dynamic settings) {
print("Settings ${settings}"); // Set Theme and notify listeners
switchLocale(Locale(settings["Locale"]));
if (settings["Theme"] == "light") { if (settings["Theme"] == "light") {
this.setLight(); this.setLight();
} else { } else {
this.setDark(); this.setDark();
} }
// Set Locale and notify listeners
switchLocale(Locale(settings["Locale"]));
// Decide whether to enable Experiments
experimentsEnabled = settings["ExperimentsEnabled"];
// Set the internal experiments map. Casting from the Map<dynamic, dynamic> that we get from JSON
experiments = new HashMap<String, bool>.from(settings["Experiments"]);
// Push the experimental settings to Consumers of Settings
notifyListeners(); notifyListeners();
} }
/// Initialize the Package Version information
initPackageInfo() { initPackageInfo() {
PackageInfo.fromPlatform().then((PackageInfo newPackageInfo) { PackageInfo.fromPlatform().then((PackageInfo newPackageInfo) {
packageInfo = newPackageInfo; packageInfo = newPackageInfo;
@ -45,13 +65,42 @@ class Settings extends ChangeNotifier {
}); });
} }
// Switch the Locale of the App
switchLocale(Locale newLocale) { switchLocale(Locale newLocale) {
locale = newLocale; locale = newLocale;
notifyListeners(); notifyListeners();
} }
/// Turn Experiments On, this will also have the side effect of enabling any
/// Experiments that have been previously activated.
enableExperiments() {
experimentsEnabled = true;
notifyListeners();
}
/// Turn Experiments Off. This will disable **all** active experiments.
/// Note: This will not set the preference for individual experiments, if experiments are enabled
/// any experiments that were active previously will become active again unless they are explicitly disabled.
disableExperiments() {
experimentsEnabled = false;
notifyListeners();
}
/// Turn on a specific experiment.
enableExperiment(String key) {
experiments.update(key, (value) => true, ifAbsent: () => true);
}
/// Turn off a specific experiment
disableExperiment(String key) {
experiments.update(key, (value) => false, ifAbsent: () => false);
}
/// Construct a default settings object.
Settings(this.locale, this.theme); Settings(this.locale, this.theme);
/// Convert this Settings object to a JSON representation for serialization on the
/// event bus.
dynamic asJson() { dynamic asJson() {
var themeString = "light"; var themeString = "light";
if (theme == Opaque.dark) { if (theme == Opaque.dark) {
@ -62,8 +111,8 @@ class Settings extends ChangeNotifier {
"Locale": this.locale.languageCode, "Locale": this.locale.languageCode,
"Theme": themeString, "Theme": themeString,
"PreviousPid": -1, "PreviousPid": -1,
"ExperimentsEnabled": false, "ExperimentsEnabled": this.experimentsEnabled,
"Experiments": {}, "Experiments": experiments,
"StateRootPane": 0, "StateRootPane": 0,
"FirstTime": false "FirstTime": false
}; };

View File

@ -47,9 +47,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
ctrlrOnion.text = Provider.of<ProfileInfoState>(context).onion; ctrlrOnion.text = Provider.of<ProfileInfoState>(context).onion;
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text(Provider.of<ProfileInfoState>(context).onion.isEmpty title: Text(Provider.of<ProfileInfoState>(context).onion.isEmpty ? AppLocalizations.of(context).addProfileTitle : AppLocalizations.of(context).editProfileTitle),
? AppLocalizations.of(context).addProfileTitle
: AppLocalizations.of(context).editProfileTitle),
), ),
body: _buildForm(), body: _buildForm(),
); );
@ -66,8 +64,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
// We used SizedBox for inter-widget height padding in columns, otherwise elements can render a little too close together. // We used SizedBox for inter-widget height padding in columns, otherwise elements can render a little too close together.
Widget _buildForm() { Widget _buildForm() {
return Consumer<Settings>(builder: (context, theme, child) { return Consumer<Settings>(builder: (context, theme, child) {
return LayoutBuilder( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
builder: (BuildContext context, BoxConstraints viewportConstraints) {
return Scrollbar( return Scrollbar(
isAlwaysShown: true, isAlwaysShown: true,
child: SingleChildScrollView( child: SingleChildScrollView(
@ -81,306 +78,184 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
child: Container( child: Container(
margin: EdgeInsets.all(30), margin: EdgeInsets.all(30),
padding: EdgeInsets.all(20), padding: EdgeInsets.all(20),
child: Column( child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [
mainAxisAlignment: MainAxisAlignment.start, Visibility(
crossAxisAlignment: CrossAxisAlignment.stretch, visible: Provider.of<ProfileInfoState>(context).onion.isNotEmpty,
children: [ child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
SizedBox(
width: 120,
height: 120,
child: ClipOval(
child: SizedBox(
width: 120,
height: 120,
child: Container(
color: Colors.white,
width: 120,
height: 120,
child: Image(
image: AssetImage("assets/" + Provider.of<ProfileInfoState>(context).imagePath),
width: 100,
height: 100,
))),
),
)
])),
Column(crossAxisAlignment: CrossAxisAlignment.start, children: [
CwtchLabel(label: AppLocalizations.of(context).displayNameLabel),
SizedBox(
height: 20,
),
CwtchTextField(
controller: ctrlrNick,
labelText: AppLocalizations.of(context).yourDisplayName,
validator: (value) {
if (value.isEmpty) {
return "Please enter a display name";
}
return null;
},
),
]),
Visibility(
visible: Provider.of<ProfileInfoState>(context).onion.isNotEmpty,
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
SizedBox(
height: 20,
),
CwtchLabel(label: AppLocalizations.of(context).addressLabel),
SizedBox(
height: 20,
),
CwtchButtonTextField(
controller: ctrlrOnion,
onPressed: _copyOnion,
icon: Icon(Icons.copy),
tooltip: AppLocalizations.of(context).copyBtn,
)
])),
// We only allow setting password types on profile creation
Visibility(
visible: Provider.of<ProfileInfoState>(context).onion.isEmpty,
child: Row(mainAxisAlignment: MainAxisAlignment.center, children: <Widget>[
Radio(
value: false,
groupValue: usePassword,
onChanged: _handleSwitchPassword,
),
Text(
AppLocalizations.of(context).radioNoPassword,
style: TextStyle(color: theme.current().mainTextColor()),
),
Radio(
value: true,
groupValue: usePassword,
onChanged: _handleSwitchPassword,
),
Text(
AppLocalizations.of(context).radioUsePassword,
style: TextStyle(color: theme.current().mainTextColor()),
),
])),
SizedBox(
height: 20,
),
Visibility(
visible: usePassword,
child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: <Widget>[
Visibility( Visibility(
visible: visible: Provider.of<ProfileInfoState>(context, listen: false).onion.isNotEmpty,
Provider.of<ProfileInfoState>(context) child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start, children: [
.onion CwtchLabel(label: AppLocalizations.of(context).currentPasswordLabel),
.isNotEmpty,
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 120,
height: 120,
child: ClipOval(
child: SizedBox(
width: 120,
height: 120,
child: Container(
color: Colors.white,
width: 120,
height: 120,
child: Image(
image: AssetImage("assets/" +
Provider.of<ProfileInfoState>(
context)
.imagePath),
width: 100,
height: 100,
))),
),
)
])),
Column(
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
CwtchLabel(
label: AppLocalizations.of(context)
.displayNameLabel),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
CwtchTextField( CwtchPasswordField(
controller: ctrlrNick, controller: ctrlrOldPass,
labelText:
AppLocalizations.of(context)
.yourDisplayName,
validator: (value) { validator: (value) {
if (value.isEmpty) { // Password field can be empty when just updating the profile, not on creation
return "Please enter a display name"; if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty && value.isEmpty && usePassword) {
return AppLocalizations.of(context).passwordErrorEmpty;
} }
return null; return null;
}, },
), ),
]), SizedBox(
Visibility( height: 20,
visible: ),
Provider.of<ProfileInfoState>(context) ])),
.onion CwtchLabel(label: AppLocalizations.of(context).password1Label),
.isNotEmpty,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
SizedBox(
height: 20,
),
CwtchLabel(
label:
AppLocalizations.of(context)
.addressLabel),
SizedBox(
height: 20,
),
CwtchButtonTextField(
controller: ctrlrOnion,
onPressed: _copyOnion,
icon: Icon(Icons.copy),
tooltip:
AppLocalizations.of(context)
.copyBtn,
)
])),
// We only allow setting password types on profile creation
Visibility(
visible:
Provider.of<ProfileInfoState>(context)
.onion
.isEmpty,
child: Row(
mainAxisAlignment:
MainAxisAlignment.center,
children: <Widget>[
Radio(
value: false,
groupValue: usePassword,
onChanged: _handleSwitchPassword,
),
Text(
AppLocalizations.of(context)
.radioNoPassword,
style: TextStyle(
color: theme
.current()
.mainTextColor()),
),
Radio(
value: true,
groupValue: usePassword,
onChanged: _handleSwitchPassword,
),
Text(
AppLocalizations.of(context)
.radioUsePassword,
style: TextStyle(
color: theme
.current()
.mainTextColor()),
),
])),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
Visibility( CwtchPasswordField(
visible: usePassword, controller: ctrlrPass,
child: Column( validator: (value) {
mainAxisAlignment: // Password field can be empty when just updating the profile, not on creation
MainAxisAlignment.start, if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty && value.isEmpty && usePassword) {
crossAxisAlignment: return AppLocalizations.of(context).passwordErrorEmpty;
CrossAxisAlignment.start, }
children: <Widget>[ if (value != ctrlrPass2.value.text) {
Visibility( return AppLocalizations.of(context).passwordErrorMatch;
visible: }
Provider.of<ProfileInfoState>( return null;
context, },
listen: false)
.onion
.isNotEmpty,
child: Column(
mainAxisAlignment:
MainAxisAlignment.start,
crossAxisAlignment:
CrossAxisAlignment.start,
children: [
CwtchLabel(
label: AppLocalizations
.of(context)
.currentPasswordLabel),
SizedBox(
height: 20,
),
CwtchPasswordField(
controller: ctrlrOldPass,
validator: (value) {
// Password field can be empty when just updating the profile, not on creation
if (Provider.of<ProfileInfoState>(
context,
listen:
false)
.onion
.isEmpty &&
value.isEmpty &&
usePassword) {
return AppLocalizations
.of(context)
.passwordErrorEmpty;
}
return null;
},
),
SizedBox(
height: 20,
),
])),
CwtchLabel(
label:
AppLocalizations.of(context)
.password1Label),
SizedBox(
height: 20,
),
CwtchPasswordField(
controller: ctrlrPass,
validator: (value) {
// Password field can be empty when just updating the profile, not on creation
if (Provider.of<ProfileInfoState>(
context,
listen: false)
.onion
.isEmpty &&
value.isEmpty &&
usePassword) {
return AppLocalizations.of(
context)
.passwordErrorEmpty;
}
if (value !=
ctrlrPass2.value.text) {
return AppLocalizations.of(
context)
.passwordErrorMatch;
}
return null;
},
),
SizedBox(
height: 20,
),
CwtchLabel(
label:
AppLocalizations.of(context)
.password2Label),
SizedBox(
height: 20,
),
CwtchPasswordField(
controller: ctrlrPass2,
validator: (value) {
// Password field can be empty when just updating the profile, not on creation
if (Provider.of<ProfileInfoState>(
context,
listen: false)
.onion
.isEmpty &&
value.isEmpty &&
usePassword) {
return AppLocalizations.of(
context)
.passwordErrorEmpty;
}
if (value !=
ctrlrPass.value.text) {
return AppLocalizations.of(
context)
.passwordErrorMatch;
}
return null;
}),
]),
), ),
SizedBox( SizedBox(
height: 20, height: 20,
), ),
ElevatedButton( CwtchLabel(label: AppLocalizations.of(context).password2Label),
onPressed: _createPressed, SizedBox(
style: ElevatedButton.styleFrom( height: 20,
primary: theme
.current()
.defaultButtonColor()),
child: Text(
Provider.of<ProfileInfoState>(context)
.onion
.isEmpty
? AppLocalizations.of(context)
.addNewProfileBtn
: AppLocalizations.of(context)
.saveProfileBtn),
), ),
Visibility( CwtchPasswordField(
visible: Provider.of<ProfileInfoState>( controller: ctrlrPass2,
context, validator: (value) {
listen: false) // Password field can be empty when just updating the profile, not on creation
.onion if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty && value.isEmpty && usePassword) {
.isNotEmpty, return AppLocalizations.of(context).passwordErrorEmpty;
child: Column( }
mainAxisAlignment: if (value != ctrlrPass.value.text) {
MainAxisAlignment.start, return AppLocalizations.of(context).passwordErrorMatch;
crossAxisAlignment: }
CrossAxisAlignment.end, return null;
children: [ }),
SizedBox( ]),
height: 20, ),
), SizedBox(
ElevatedButton.icon( height: 20,
onPressed: () { ),
showAlertDialog(context); ElevatedButton(
}, onPressed: _createPressed,
style: ElevatedButton.styleFrom( style: ElevatedButton.styleFrom(primary: theme.current().defaultButtonColor()),
primary: theme child: Text(Provider.of<ProfileInfoState>(context).onion.isEmpty ? AppLocalizations.of(context).addNewProfileBtn : AppLocalizations.of(context).saveProfileBtn),
.current() ),
.defaultButtonColor()), Visibility(
icon: Icon(Icons.delete_forever), visible: Provider.of<ProfileInfoState>(context, listen: false).onion.isNotEmpty,
label: Text( child: Column(mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.end, children: [
AppLocalizations.of(context) SizedBox(
.deleteBtn), height: 20,
) ),
])) Tooltip(
])))))); message: AppLocalizations.of(context).enterCurrentPasswordForDelete,
child: ElevatedButton.icon(
onPressed: checkCurrentPassword()
? null
: () {
showAlertDialog(context);
},
style: ElevatedButton.styleFrom(primary: theme.current().defaultButtonColor()),
icon: Icon(Icons.delete_forever),
label: Text(AppLocalizations.of(context).deleteBtn),
))
]))
]))))));
}); });
}); });
} }
void _copyOnion() { void _copyOnion() {
Clipboard.setData(new ClipboardData( Clipboard.setData(new ClipboardData(text: Provider.of<ProfileInfoState>(context, listen: false).onion));
text: Provider.of<ProfileInfoState>(context, listen: false).onion));
// TODO Toast // TODO Toast
} }
@ -391,14 +266,10 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
if (_formKey.currentState.validate()) { if (_formKey.currentState.validate()) {
if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty) { if (Provider.of<ProfileInfoState>(context, listen: false).onion.isEmpty) {
if (usePassword == true) { if (usePassword == true) {
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text);
.cwtch
.CreateProfile(ctrlrNick.value.text, ctrlrPass.value.text);
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.CreateProfile(ctrlrNick.value.text, "be gay do crime");
.cwtch
.CreateProfile(ctrlrNick.value.text, "be gay do crime");
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} else { } else {
@ -411,11 +282,7 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
}; };
final json = jsonEncode(event); final json = jsonEncode(event);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.SendProfileEvent(Provider.of<ProfileInfoState>(context, listen: false).onion, json);
.cwtch
.SendProfileEvent(
Provider.of<ProfileInfoState>(context, listen: false).onion,
json);
Navigator.of(context).pop(); Navigator.of(context).pop();
} else { } else {
// At this points passwords have been validated to be the same and not empty // At this points passwords have been validated to be the same and not empty
@ -426,32 +293,26 @@ class _AddEditProfileViewState extends State<AddEditProfileView> {
}; };
final updateNameEventJson = jsonEncode(updateNameEvent); final updateNameEventJson = jsonEncode(updateNameEvent);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.SendProfileEvent(Provider.of<ProfileInfoState>(context, listen: false).onion, updateNameEventJson);
.cwtch
.SendProfileEvent(
Provider.of<ProfileInfoState>(context, listen: false).onion,
updateNameEventJson);
final updatePasswordEvent = { final updatePasswordEvent = {
"EventType": "ChangePassword", "EventType": "ChangePassword",
"Data": { "Data": {"Password": ctrlrOldPass.text, "NewPassword": ctrlrPass.text}
"Password": ctrlrOldPass.text,
"NewPassword": ctrlrPass.text
}
}; };
final updatePasswordEventJson = jsonEncode(updatePasswordEvent); final updatePasswordEventJson = jsonEncode(updatePasswordEvent);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.SendProfileEvent(Provider.of<ProfileInfoState>(context, listen: false).onion, updatePasswordEventJson);
.cwtch
.SendProfileEvent(
Provider.of<ProfileInfoState>(context, listen: false).onion,
updatePasswordEventJson);
Navigator.of(context).pop(); Navigator.of(context).pop();
} }
} }
} }
} }
// TODO Stub - wire this into a libCwtch call.
bool checkCurrentPassword() {
return ctrlrOldPass.value.text.isEmpty;
}
} }
showAlertDialog(BuildContext context) { showAlertDialog(BuildContext context) {
@ -459,12 +320,9 @@ showAlertDialog(BuildContext context) {
Widget cancelButton = TextButton( Widget cancelButton = TextButton(
child: Text("Cancel"), child: Text("Cancel"),
style: ButtonStyle( style: ButtonStyle(
backgroundColor: backgroundColor: MaterialStateProperty.all(Opaque.current().defaultButtonColor()),
MaterialStateProperty.all(Opaque.current().defaultButtonColor()), foregroundColor: MaterialStateProperty.all(Opaque.current().defaultButtonTextColor()),
foregroundColor: MaterialStateProperty.all( overlayColor: MaterialStateProperty.all(Opaque.current().defaultButtonActiveColor()),
Opaque.current().defaultButtonTextColor()),
overlayColor: MaterialStateProperty.all(
Opaque.current().defaultButtonActiveColor()),
padding: MaterialStateProperty.all(EdgeInsets.all(20))), padding: MaterialStateProperty.all(EdgeInsets.all(20))),
onPressed: () { onPressed: () {
Navigator.of(context).pop(); // dismiss dialog Navigator.of(context).pop(); // dismiss dialog
@ -472,12 +330,9 @@ showAlertDialog(BuildContext context) {
); );
Widget continueButton = TextButton( Widget continueButton = TextButton(
style: ButtonStyle( style: ButtonStyle(
backgroundColor: backgroundColor: MaterialStateProperty.all(Opaque.current().defaultButtonColor()),
MaterialStateProperty.all(Opaque.current().defaultButtonColor()), foregroundColor: MaterialStateProperty.all(Opaque.current().defaultButtonTextColor()),
foregroundColor: MaterialStateProperty.all( overlayColor: MaterialStateProperty.all(Opaque.current().defaultButtonActiveColor()),
Opaque.current().defaultButtonTextColor()),
overlayColor: MaterialStateProperty.all(
Opaque.current().defaultButtonActiveColor()),
padding: MaterialStateProperty.all(EdgeInsets.all(20))), padding: MaterialStateProperty.all(EdgeInsets.all(20))),
child: Text(AppLocalizations.of(context).deleteProfileConfirmBtn), child: Text(AppLocalizations.of(context).deleteProfileConfirmBtn),
onPressed: () { onPressed: () {

View File

@ -18,11 +18,7 @@ class _ContactsViewState extends State<ContactsView> {
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar( appBar: AppBar(
title: Text("%1's contacts".replaceAll( title: Text("%1's contacts".replaceAll("%1", Provider.of<ProfileInfoState>(context).nickname ?? Provider.of<ProfileInfoState>(context).onion ?? '')), //todo
"%1",
Provider.of<ProfileInfoState>(context).nickname ??
Provider.of<ProfileInfoState>(context).onion ??
'')), //todo
actions: [ actions: [
IconButton( IconButton(
icon: Icon(Icons.copy), icon: Icon(Icons.copy),
@ -41,9 +37,12 @@ class _ContactsViewState extends State<ContactsView> {
Widget _buildContactList() { Widget _buildContactList() {
final tiles = Provider.of<ContactListState>(context).contacts.map((ContactInfoState contact) { final tiles = Provider.of<ContactListState>(context).contacts.map((ContactInfoState contact) {
return ChangeNotifierProvider<ContactInfoState>.value(value: contact, child: ContactRow()); return ChangeNotifierProvider<ContactInfoState>.value(value: contact, child: ContactRow());
}); });
final divided = ListTile.divideTiles(context: context, tiles: tiles, ).toList(); final divided = ListTile.divideTiles(
context: context,
tiles: tiles,
).toList();
return ListView(children: divided); return ListView(children: divided);
} }
@ -59,9 +58,7 @@ class _ContactsViewState extends State<ContactsView> {
} }
void _copyOnion() { void _copyOnion() {
final snackBar = SnackBar( final snackBar = SnackBar(content: Text(AppLocalizations.of(context).copiedClipboardNotification)); //todo
content: Text(
AppLocalizations.of(context).copiedClipboardNotification)); //todo
// Find the Scaffold in the widget tree and use it to show a SnackBar. // Find the Scaffold in the widget tree and use it to show a SnackBar.
ScaffoldMessenger.of(context).showSnackBar(snackBar); ScaffoldMessenger.of(context).showSnackBar(snackBar);
} }

View File

@ -26,10 +26,7 @@ class _DoubleColumnViewState extends State<DoubleColumnView> {
child: flwtch.selectedConversation == "" child: flwtch.selectedConversation == ""
? Center(child: Text("pick a contact")) ? Center(child: Text("pick a contact"))
: //dev : //dev
Container( Container(child: MessageView(profile: flwtch.selectedProfile, conversationHandle: flwtch.selectedConversation)),
child: MessageView(
profile: flwtch.selectedProfile,
conversationHandle: flwtch.selectedConversation)),
), ),
], ],
); );

View File

@ -9,6 +9,7 @@ import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../main.dart'; import '../main.dart';
/// Global Settings View provides access to modify all the Globally Relevant Settings including Locale, Theme and Experiments.
class GlobalSettingsView extends StatefulWidget { class GlobalSettingsView extends StatefulWidget {
@override @override
_GlobalSettingsViewState createState() => _GlobalSettingsViewState(); _GlobalSettingsViewState createState() => _GlobalSettingsViewState();
@ -31,69 +32,103 @@ class _GlobalSettingsViewState extends State<GlobalSettingsView> {
} }
Widget _buildSettingsList() { Widget _buildSettingsList() {
return Consumer<Settings>(builder: (context, theme, child) { return Consumer<Settings>(builder: (context, settings, child) {
return Center( return LayoutBuilder(builder: (BuildContext context, BoxConstraints viewportConstraints) {
child: Column(children: [ return Scrollbar(
ListTile( isAlwaysShown: true,
title: Text(AppLocalizations.of(context).settingLanguage, child: SingleChildScrollView(
style: TextStyle(color: theme.current().mainTextColor())), clipBehavior: Clip.antiAlias,
leading: child: ConstrainedBox(
Icon(Icons.language, color: theme.current().mainTextColor()), constraints: BoxConstraints(
trailing: DropdownButton( minHeight: viewportConstraints.maxHeight,
value: Provider.of<Settings>(context).locale.languageCode, ),
onChanged: (String newValue) { child: Column(children: [
setState(() { ListTile(
var settings = title: Text(AppLocalizations.of(context).settingLanguage, style: TextStyle(color: settings.current().mainTextColor())),
Provider.of<Settings>(context, listen: false); leading: Icon(Icons.language, color: settings.current().mainTextColor()),
settings.switchLocale(Locale(newValue, '')); trailing: DropdownButton(
saveSettings(context); value: Provider.of<Settings>(context).locale.languageCode,
}); onChanged: (String newValue) {
}, setState(() {
items: AppLocalizations.supportedLocales settings.switchLocale(Locale(newValue, ''));
.map<DropdownMenuItem<String>>((Locale value) { saveSettings(context);
return DropdownMenuItem<String>( });
value: value.languageCode, },
child: Text(getLanguageFull(context, value.languageCode)), items: AppLocalizations.supportedLocales.map<DropdownMenuItem<String>>((Locale value) {
); return DropdownMenuItem<String>(
}).toList())), value: value.languageCode,
SwitchListTile( child: Text(getLanguageFull(context, value.languageCode)),
title: Text(AppLocalizations.of(context).settingTheme, );
style: TextStyle(color: theme.current().mainTextColor())), }).toList())),
value: theme.current() == Opaque.light, SwitchListTile(
onChanged: (bool value) { title: Text(AppLocalizations.of(context).settingTheme, style: TextStyle(color: settings.current().mainTextColor())),
if (value) { value: settings.current() == Opaque.light,
theme.setLight(); onChanged: (bool value) {
} else { if (value) {
theme.setDark(); settings.setLight();
} } else {
settings.setDark();
}
// Save Settings... // Save Settings...
saveSettings(context); saveSettings(context);
}, },
secondary: Icon(Icons.lightbulb_outline, secondary: Icon(Icons.lightbulb_outline, color: settings.current().mainTextColor()),
color: theme.current().mainTextColor()), ),
), SwitchListTile(
AboutListTile( title: Text(AppLocalizations.of(context).experimentsEnabled, style: TextStyle(color: settings.current().mainTextColor())),
icon: Icon(Icons.info, color: theme.current().mainTextColor()), value: settings.experimentsEnabled,
applicationIcon: Padding( onChanged: (bool value) {
padding: EdgeInsets.all(20), if (value) {
child: Image( settings.enableExperiments();
image: AssetImage("assets/knott.png"), } else {
width: 128, settings.disableExperiments();
height: 128, }
)), // Save Settings...
applicationName: "Cwtch (Flutter UI)", saveSettings(context);
applicationVersion: AppLocalizations.of(context).version.replaceAll( },
"%1", secondary: Icon(Icons.science, color: settings.current().mainTextColor()),
constructVersionString( ),
Provider.of<Settings>(context).packageInfo)), Visibility(
applicationLegalese: '\u{a9} 2021 Open Privacy Research Society', visible: settings.experimentsEnabled,
), child: Column(
])); children: [
SwitchListTile(
title: Text(AppLocalizations.of(context).enableGroups, style: TextStyle(color: settings.current().mainTextColor())),
value: settings.experiments.containsKey("tapir-groups-experiment") && settings.experiments["tapir-groups-experiment"],
onChanged: (bool value) {
if (value) {
settings.enableExperiment("tapir-groups-experiment");
} else {
settings.disableExperiment("tapir-groups-experiment");
}
// Save Settings...
saveSettings(context);
},
secondary: Icon(Icons.group_sharp, color: settings.current().mainTextColor()),
),
],
)),
AboutListTile(
icon: Icon(Icons.info, color: settings.current().mainTextColor()),
applicationIcon: Padding(
padding: EdgeInsets.all(20),
child: Image(
image: AssetImage("assets/knott.png"),
width: 128,
height: 128,
)),
applicationName: "Cwtch (Flutter UI)",
applicationVersion: AppLocalizations.of(context).version.replaceAll("%1", constructVersionString(Provider.of<Settings>(context).packageInfo)),
applicationLegalese: '\u{a9} 2021 Open Privacy Research Society',
),
]))));
});
}); });
} }
} }
/// Construct a version string from Package Info
String constructVersionString(PackageInfo pinfo) { String constructVersionString(PackageInfo pinfo) {
if (pinfo == null) { if (pinfo == null) {
return ""; return "";
@ -101,6 +136,8 @@ String constructVersionString(PackageInfo pinfo) {
return pinfo.version + "." + pinfo.buildNumber; return pinfo.version + "." + pinfo.buildNumber;
} }
/// A slightly verbose way to extract the full language name from
/// an individual language code. There might be a more efficient way of doing this.
String getLanguageFull(context, String languageCode) { String getLanguageFull(context, String languageCode) {
if (languageCode == "en") { if (languageCode == "en") {
return AppLocalizations.of(context).localeEn; return AppLocalizations.of(context).localeEn;
@ -123,6 +160,7 @@ String getLanguageFull(context, String languageCode) {
return languageCode; return languageCode;
} }
/// Send an UpdateGlobalSettings to the Event Bus
saveSettings(context) { saveSettings(context) {
var settings = Provider.of<Settings>(context, listen: false); var settings = Provider.of<Settings>(context, listen: false);
final updateSettingsEvent = { final updateSettingsEvent = {
@ -130,7 +168,5 @@ saveSettings(context) {
"Data": {"Data": jsonEncode(settings.asJson())}, "Data": {"Data": jsonEncode(settings.asJson())},
}; };
final updateSettingsEventJson = jsonEncode(updateSettingsEvent); final updateSettingsEventJson = jsonEncode(updateSettingsEvent);
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.SendAppEvent(updateSettingsEventJson);
.cwtch
.SendAppEvent(updateSettingsEventJson);
} }

View File

@ -5,8 +5,7 @@ import '../opaque.dart';
import '../widgets/messagelist.dart'; import '../widgets/messagelist.dart';
class MessageView extends StatefulWidget { class MessageView extends StatefulWidget {
const MessageView({Key key, this.profile, this.conversationHandle}) const MessageView({Key key, this.profile, this.conversationHandle}) : super(key: key);
: super(key: key);
final ProfileInfoState profile; final ProfileInfoState profile;
final String conversationHandle; final String conversationHandle;
@ -35,9 +34,7 @@ class _MessageViewState extends State<MessageView> {
IconButton(icon: Icon(Icons.settings), onPressed: _pushConvoSettings), IconButton(icon: Icon(Icons.settings), onPressed: _pushConvoSettings),
], ],
), ),
body: MessageList( body: MessageList(profile: widget.profile, conversationHandle: widget.conversationHandle),
profile: widget.profile,
conversationHandle: widget.conversationHandle),
bottomSheet: _buildComposeBox(), bottomSheet: _buildComposeBox(),
); );
} }
@ -62,25 +59,15 @@ class _MessageViewState extends State<MessageView> {
height: 80, height: 80,
child: Column(children: <Widget>[ child: Column(children: <Widget>[
ElevatedButton( ElevatedButton(
child: child: Icon(Icons.send, color: Opaque.current().mainTextColor()),
Icon(Icons.send, color: Opaque.current().mainTextColor()),
style: ButtonStyle( style: ButtonStyle(
backgroundColor: MaterialStateProperty.all( backgroundColor: MaterialStateProperty.all(Opaque.current().defaultButtonColor()),
Opaque.current().defaultButtonColor()),
), ),
onPressed: _sendMessage, onPressed: _sendMessage,
), ),
Row(children: <Widget>[ Row(children: <Widget>[
SizedBox( SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.emoji_emotions_outlined, color: Opaque.current().mainTextColor()))),
width: 45, SizedBox(width: 45, child: ElevatedButton(child: Icon(Icons.attach_file, color: Opaque.current().mainTextColor()))),
child: ElevatedButton(
child: Icon(Icons.emoji_emotions_outlined,
color: Opaque.current().mainTextColor()))),
SizedBox(
width: 45,
child: ElevatedButton(
child: Icon(Icons.attach_file,
color: Opaque.current().mainTextColor()))),
]) ])
]), ]),
), ),

View File

@ -29,15 +29,12 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
appBar: AppBar( appBar: AppBar(
title: Text(AppLocalizations.of(context).profileName), title: Text(AppLocalizations.of(context).profileName),
actions: [ actions: [
IconButton( IconButton(icon: Icon(Icons.bug_report_outlined), onPressed: _testChangingContactInfo),
icon: Icon(Icons.bug_report_outlined),
onPressed: _testChangingContactInfo),
IconButton( IconButton(
icon: Icon(Icons.lock_open), icon: Icon(Icons.lock_open),
onPressed: _modalUnlockProfiles, onPressed: _modalUnlockProfiles,
), ),
IconButton( IconButton(icon: Icon(Icons.settings), onPressed: _pushGlobalSettings),
icon: Icon(Icons.settings), onPressed: _pushGlobalSettings),
], ],
), ),
floatingActionButton: FloatingActionButton( floatingActionButton: FloatingActionButton(
@ -50,7 +47,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
} }
void _testChangingContactInfo() { void _testChangingContactInfo() {
Provider.of<ProfileListState>(context, listen:false).profiles.first.nickname = "yay!"; Provider.of<ProfileListState>(context, listen: false).profiles.first.nickname = "yay!";
} }
void _pushGlobalSettings() { void _pushGlobalSettings() {
@ -103,9 +100,7 @@ class _ProfileMgrViewState extends State<ProfileMgrView> {
ElevatedButton( ElevatedButton(
child: Text(AppLocalizations.of(context).unlock), child: Text(AppLocalizations.of(context).unlock),
onPressed: () { onPressed: () {
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.LoadProfiles(ctrlrPassword.value.text);
.cwtch
.LoadProfiles(ctrlrPassword.value.text);
Navigator.pop(context); Navigator.pop(context);
}, },
), ),

View File

@ -22,19 +22,14 @@ class _TripleColumnViewState extends State<TripleColumnView> {
), ),
Flexible( Flexible(
flex: flwtch.columns[1], flex: flwtch.columns[1],
child: flwtch.selectedProfile == null child: flwtch.selectedProfile == null ? Center(child: Text("pick a profile")) : ContactsView(), //dev
? Center(child: Text("pick a profile"))
: ContactsView(), //dev
), ),
Flexible( Flexible(
flex: flwtch.columns[2], flex: flwtch.columns[2],
child: flwtch.selectedConversation == "" child: flwtch.selectedConversation == ""
? Center(child: Text("pick a contact")) ? Center(child: Text("pick a contact"))
: //dev : //dev
Container( Container(child: MessageView(profile: flwtch.selectedProfile, conversationHandle: flwtch.selectedConversation)),
child: MessageView(
profile: flwtch.selectedProfile,
conversationHandle: flwtch.selectedConversation)),
), ),
]); ]);
} }

View File

@ -1,13 +1,11 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_app/settings.dart'; import 'package:flutter_app/settings.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../opaque.dart';
// Provides a styled Text Field for use in Form Widgets. // Provides a styled Text Field for use in Form Widgets.
// Callers must provide a text controller, label helper text and a validator. // Callers must provide a text controller, label helper text and a validator.
class CwtchButtonTextField extends StatefulWidget { class CwtchButtonTextField extends StatefulWidget {
CwtchButtonTextField( CwtchButtonTextField({this.controller, this.onPressed, this.icon, this.tooltip});
{this.controller, this.onPressed, this.icon, this.tooltip});
final TextEditingController controller; final TextEditingController controller;
final Function onPressed; final Function onPressed;
final Icon icon; final Icon icon;
@ -37,32 +35,17 @@ class _CwtchButtonTextFieldState extends State<CwtchButtonTextField> {
), ),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
filled: true, filled: true,
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0)),
borderRadius: BorderRadius.circular(15.0), focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
borderSide: BorderSide( errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
color: theme.current().textfieldBorderColor(), width: 3.0)),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
errorStyle: TextStyle( errorStyle: TextStyle(
color: theme.current().textfieldErrorColor(), color: theme.current().textfieldErrorColor(),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
fillColor: theme.current().textfieldBackgroundColor(), fillColor: theme.current().textfieldBackgroundColor(),
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0))),
borderRadius: BorderRadius.circular(15.0), style: TextStyle(color: theme.current().mainTextColor(), backgroundColor: theme.current().textfieldBackgroundColor()),
borderSide: BorderSide(
color: theme.current().textfieldBorderColor(),
width: 3.0))),
style: TextStyle(
color: theme.current().mainTextColor(),
backgroundColor: theme.current().textfieldBackgroundColor()),
); );
}); });
} }

View File

@ -20,16 +20,23 @@ class _ContactRowState extends State<ContactRow> {
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/"+contact.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/" + contact.imagePath),
width: 50,
height: 50,
))),
), ),
), ),
trailing: contact.isInvitation != null && contact.isInvitation trailing: contact.isInvitation != null && contact.isInvitation
? Column(children: <Widget>[ ? Column(children: <Widget>[Icon(Icons.favorite, color: Opaque.current().mainTextColor()), Icon(Icons.delete, color: Opaque.current().mainTextColor())])
Icon(Icons.favorite, color: Opaque.current().mainTextColor()), : Text("99+"), //(nb: Icons.create is a pencil and we use it for "edit", not create)
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( title: Text(
contact.nickname, contact.nickname,
style: Provider.of<FlwtchState>(context).biggerFont, style: Provider.of<FlwtchState>(context).biggerFont,

View File

@ -1,7 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../opaque.dart';
import '../settings.dart'; import '../settings.dart';
// Provides a styled Label // Provides a styled Label

View File

@ -24,15 +24,8 @@ class _MessageBubbleState extends State<MessageBubble> {
super.didChangeDependencies(); super.didChangeDependencies();
print("requesting message " + widget.messageIndex.toString()); print("requesting message " + widget.messageIndex.toString());
Provider.of<FlwtchState>(context) Provider.of<FlwtchState>(context).cwtch.GetMessage(widget.profile.onion, widget.contactOnion, widget.messageIndex).then((jsonMessage) {
.cwtch print("got message: " + widget.messageIndex.toString() + ": " + jsonMessage);
.GetMessage(
widget.profile.onion, widget.contactOnion, widget.messageIndex)
.then((jsonMessage) {
print("got message: " +
widget.messageIndex.toString() +
": " +
jsonMessage);
dynamic messageWrapper = jsonDecode(jsonMessage); dynamic messageWrapper = jsonDecode(jsonMessage);
dynamic message = jsonDecode(messageWrapper['Message']); dynamic message = jsonDecode(messageWrapper['Message']);
setState(() { setState(() {
@ -50,9 +43,7 @@ class _MessageBubbleState extends State<MessageBubble> {
child: Container( child: Container(
decoration: BoxDecoration( decoration: BoxDecoration(
color: Opaque.current().messageFromOtherBackgroundColor(), color: Opaque.current().messageFromOtherBackgroundColor(),
border: Border.all( border: Border.all(color: Opaque.current().messageFromOtherBackgroundColor(), width: 1),
color: Opaque.current().messageFromOtherBackgroundColor(),
width: 1),
borderRadius: BorderRadius.all( borderRadius: BorderRadius.all(
Radius.circular(15.0), Radius.circular(15.0),
), ),
@ -65,11 +56,7 @@ class _MessageBubbleState extends State<MessageBubble> {
subtitle: Row( subtitle: Row(
children: [ children: [
Text("" + widget.messageIndex.toString()), Text("" + widget.messageIndex.toString()),
ack ack ? Icon(Icons.check_circle_outline, color: Opaque.current().mainTextColor()) : Icon(Icons.hourglass_bottom_outlined, color: Opaque.current().mainTextColor())
? Icon(Icons.check_circle_outline,
color: Opaque.current().mainTextColor())
: Icon(Icons.hourglass_bottom_outlined,
color: Opaque.current().mainTextColor())
], ],
), ),
), ),

View File

@ -10,8 +10,7 @@ class MessageList extends StatefulWidget {
final ProfileInfoState profile; final ProfileInfoState profile;
final String conversationHandle; final String conversationHandle;
const MessageList({Key key, this.profile, this.conversationHandle}) const MessageList({Key key, this.profile, this.conversationHandle}) : super(key: key);
: super(key: key);
@override @override
_MessageListState createState() => _MessageListState(); _MessageListState createState() => _MessageListState();
@ -50,14 +49,8 @@ class _MessageListState extends State<MessageList> {
return; return;
} }
Provider.of<FlwtchState>(context, listen: false) Provider.of<FlwtchState>(context, listen: false).cwtch.NumMessages(Provider.of<ProfileInfoState>(context, listen: false).onion, widget.conversationHandle).then((n) {
.cwtch if (n != conversationNumMessages) setState(() => conversationNumMessages = n);
.NumMessages(
Provider.of<ProfileInfoState>(context, listen: false).onion,
widget.conversationHandle)
.then((n) {
if (n != conversationNumMessages)
setState(() => conversationNumMessages = n);
}); });
} }
} }

View File

@ -1,7 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import '../opaque.dart';
import '../settings.dart'; import '../settings.dart';
// Provides a styled Password Input Field for use in Form Widgets. // Provides a styled Password Input Field for use in Form Widgets.
@ -30,28 +28,14 @@ class _CwtchTextFieldState extends State<CwtchPasswordField> {
color: theme.current().textfieldErrorColor(), color: theme.current().textfieldErrorColor(),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0)),
borderRadius: BorderRadius.circular(15.0), focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
borderSide: BorderSide( errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
color: theme.current().textfieldBorderColor(), width: 3.0)),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
filled: true, filled: true,
fillColor: theme.current().textfieldBackgroundColor(), fillColor: theme.current().textfieldBackgroundColor(),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0)),
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldBorderColor(), width: 3.0)),
), ),
style: TextStyle( style: TextStyle(color: theme.current().mainTextColor(), backgroundColor: theme.current().textfieldBackgroundColor()),
color: theme.current().mainTextColor(),
backgroundColor: theme.current().textfieldBackgroundColor()),
); );
}); });
} }

View File

@ -6,7 +6,6 @@ import 'package:provider/provider.dart';
import '../main.dart'; import '../main.dart';
import '../model.dart'; import '../model.dart';
import '../opaque.dart';
import '../settings.dart'; import '../settings.dart';
class ProfileRow extends StatefulWidget { class ProfileRow extends StatefulWidget {
@ -38,13 +37,9 @@ class _ProfileRowState extends State<ProfileRow> {
), ),
), ),
trailing: IconButton( trailing: IconButton(
icon: Icon(Icons.create, icon: Icon(Icons.create, color: Provider.of<Settings>(context).current().mainTextColor()),
color: Provider.of<Settings>(context).current().mainTextColor()),
onPressed: () { onPressed: () {
_pushAddEditProfile( _pushAddEditProfile(onion: profile.onion, displayName: profile.nickname, profileImage: profile.imagePath);
onion: profile.onion,
displayName: profile.nickname,
profileImage: profile.imagePath);
}, },
), //(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(
@ -83,8 +78,7 @@ class _ProfileRowState extends State<ProfileRow> {
ChangeNotifierProvider<ProfileInfoState>.value(value: profile), ChangeNotifierProvider<ProfileInfoState>.value(value: profile),
ChangeNotifierProvider<ContactListState>.value(value: profile.contactList), ChangeNotifierProvider<ContactListState>.value(value: profile.contactList),
], ],
builder: (context, widget) => builder: (context, widget) => includeDoublePane ? DoubleColumnView() : ContactsView(),
includeDoublePane ? DoubleColumnView() : ContactsView(),
); );
}, },
), ),
@ -97,8 +91,7 @@ class _ProfileRowState extends State<ProfileRow> {
return MultiProvider( return MultiProvider(
providers: [ providers: [
ChangeNotifierProvider<ProfileInfoState>( ChangeNotifierProvider<ProfileInfoState>(
create: (_) => ProfileInfoState( create: (_) => ProfileInfoState(onion: onion, nickname: displayName, imagePath: profileImage),
onion: onion, nickname: displayName, imagePath: profileImage),
), ),
], ],
builder: (context, widget) => AddEditProfileView(), builder: (context, widget) => AddEditProfileView(),

View File

@ -1,6 +1,5 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import '../opaque.dart';
import '../settings.dart'; import '../settings.dart';
// Provides a styled Text Field for use in Form Widgets. // Provides a styled Text Field for use in Form Widgets.
@ -24,37 +23,20 @@ class _CwtchTextFieldState extends State<CwtchTextField> {
validator: widget.validator, validator: widget.validator,
decoration: InputDecoration( decoration: InputDecoration(
labelText: widget.labelText, labelText: widget.labelText,
labelStyle: TextStyle( labelStyle: TextStyle(color: theme.current().mainTextColor(), backgroundColor: theme.current().textfieldBackgroundColor()),
color: theme.current().mainTextColor(),
backgroundColor: theme.current().textfieldBackgroundColor()),
floatingLabelBehavior: FloatingLabelBehavior.never, floatingLabelBehavior: FloatingLabelBehavior.never,
filled: true, filled: true,
focusedBorder: OutlineInputBorder( focusedBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0)),
borderRadius: BorderRadius.circular(15.0), focusedErrorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
borderSide: BorderSide( errorBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldErrorColor(), width: 3.0)),
color: theme.current().textfieldBorderColor(), width: 3.0)),
focusedErrorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
errorBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(15.0),
borderSide: BorderSide(
color: theme.current().textfieldErrorColor(), width: 3.0)),
errorStyle: TextStyle( errorStyle: TextStyle(
color: theme.current().textfieldErrorColor(), color: theme.current().textfieldErrorColor(),
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
fillColor: theme.current().textfieldBackgroundColor(), fillColor: theme.current().textfieldBackgroundColor(),
contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0), contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
enabledBorder: OutlineInputBorder( enabledBorder: OutlineInputBorder(borderRadius: BorderRadius.circular(15.0), borderSide: BorderSide(color: theme.current().textfieldBorderColor(), width: 3.0))),
borderRadius: BorderRadius.circular(15.0), style: TextStyle(color: theme.current().mainTextColor(), backgroundColor: theme.current().textfieldBackgroundColor()),
borderSide: BorderSide(
color: theme.current().textfieldBorderColor(),
width: 3.0))),
style: TextStyle(
color: theme.current().mainTextColor(),
backgroundColor: theme.current().textfieldBackgroundColor()),
); );
}); });
} }

View File

@ -18,9 +18,7 @@ class _TorStatusState extends State<TorStatusLabel> {
stream: Provider.of<FlwtchState>(context).appStatus.torStatus(), stream: Provider.of<FlwtchState>(context).appStatus.torStatus(),
builder: (BuildContext context, AsyncSnapshot<String> snapshot) { builder: (BuildContext context, AsyncSnapshot<String> snapshot) {
return Text( return Text(
snapshot.hasData snapshot.hasData ? snapshot.data : AppLocalizations.of(context).loadingTor,
? snapshot.data
: AppLocalizations.of(context).loadingTor,
style: Theme.of(context).textTheme.headline4, style: Theme.of(context).textTheme.headline4,
); );
}, },

View File

@ -35,7 +35,6 @@ dependencies:
ffi: ^1.0.0 ffi: ^1.0.0
path_provider: ^2.0.0 path_provider: ^2.0.0
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter