2021-01-13 23:17:02 +00:00
|
|
|
import 'dart:collection';
|
2021-01-12 06:21:18 +00:00
|
|
|
import 'package:flutter_app/cwtch/ffi.dart';
|
2021-01-13 05:47:20 +00:00
|
|
|
import 'package:flutter_app/cwtch/gomobile.dart';
|
2021-01-06 23:09:58 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2021-01-21 20:37:35 +00:00
|
|
|
import 'package:flutter_app/views/triplecolview.dart';
|
2021-01-07 19:38:06 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2021-01-12 06:21:18 +00:00
|
|
|
import 'cwtch/cwtch.dart';
|
2021-02-09 23:47:12 +00:00
|
|
|
import 'cwtch/cwtchNotifier.dart';
|
2021-01-07 19:38:06 +00:00
|
|
|
import 'model.dart';
|
|
|
|
import 'views/profilemgrview.dart';
|
2021-01-13 23:17:02 +00:00
|
|
|
import 'views/splashView.dart';
|
2021-01-10 07:22:31 +00:00
|
|
|
import 'dart:io' show Platform;
|
2021-01-21 20:37:35 +00:00
|
|
|
import 'opaque.dart';
|
2021-02-23 02:55:10 +00:00
|
|
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
|
|
|
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
2021-01-07 19:38:06 +00:00
|
|
|
void main() => runApp(Flwtch());
|
2021-01-06 23:09:58 +00:00
|
|
|
|
2021-01-07 19:38:06 +00:00
|
|
|
class Flwtch extends StatefulWidget {
|
|
|
|
final Key flwtch = GlobalKey();
|
2021-01-06 23:09:58 +00:00
|
|
|
|
2021-01-07 19:38:06 +00:00
|
|
|
@override
|
|
|
|
FlwtchState createState() => FlwtchState();
|
2021-01-06 23:09:58 +00:00
|
|
|
}
|
|
|
|
|
2021-01-07 19:38:06 +00:00
|
|
|
class FlwtchState extends State<Flwtch> {
|
|
|
|
final TextStyle biggerFont = const TextStyle(fontSize: 18);
|
2021-01-12 06:21:18 +00:00
|
|
|
Cwtch cwtch;
|
2021-01-13 23:17:02 +00:00
|
|
|
bool cwtchInit = false;
|
2021-02-03 11:22:25 +00:00
|
|
|
ProfileInfoState selectedProfile;
|
2021-01-21 20:37:35 +00:00
|
|
|
String selectedConversation = "";
|
2021-01-27 20:18:28 +00:00
|
|
|
var columns = [1]; // default or 'single column' mode
|
2021-01-21 20:37:35 +00:00
|
|
|
//var columns = [1, 1, 2];
|
2021-01-07 19:38:06 +00:00
|
|
|
AppModel appStatus;
|
2021-02-03 11:22:25 +00:00
|
|
|
ProfileListState profs;
|
2021-01-13 05:47:20 +00:00
|
|
|
|
2021-01-10 07:22:31 +00:00
|
|
|
@override
|
|
|
|
initState() {
|
|
|
|
super.initState();
|
2021-01-13 23:17:02 +00:00
|
|
|
cwtchInit = false;
|
2021-02-03 11:22:25 +00:00
|
|
|
profs = ProfileListState();
|
2021-02-09 23:47:12 +00:00
|
|
|
var cwtchNotifier = new CwtchNotifier(profs);
|
2021-01-10 07:22:31 +00:00
|
|
|
|
|
|
|
if (Platform.isAndroid) {
|
2021-02-09 23:47:12 +00:00
|
|
|
cwtch = CwtchGomobile(cwtchNotifier);
|
2021-01-13 05:47:20 +00:00
|
|
|
} else {
|
2021-02-09 23:47:12 +00:00
|
|
|
cwtch = CwtchFfi(cwtchNotifier);
|
2021-01-10 07:22:31 +00:00
|
|
|
}
|
2021-02-03 11:22:25 +00:00
|
|
|
|
2021-01-13 23:17:02 +00:00
|
|
|
cwtch.Start().then((val) {
|
|
|
|
setState(() {
|
|
|
|
cwtchInit = true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
appStatus = AppModel(cwtch: cwtch);
|
2021-01-27 20:18:28 +00:00
|
|
|
}
|
|
|
|
|
2021-02-03 11:22:25 +00:00
|
|
|
ChangeNotifierProvider<OpaqueTheme> getOpaqueProvider() => ChangeNotifierProvider(create: (context) => OpaqueTheme(Opaque.dark));
|
|
|
|
Provider<FlwtchState> getFlwtchStateProvider() => Provider<FlwtchState>(create: (_) => this);
|
|
|
|
ChangeNotifierProvider<ProfileListState> getProfileListProvider() => ChangeNotifierProvider(create: (context) => profs);
|
2021-01-27 20:18:28 +00:00
|
|
|
|
2021-01-06 23:09:58 +00:00
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
2021-01-22 07:56:30 +00:00
|
|
|
appStatus = AppModel(cwtch: cwtch);
|
2021-01-06 23:09:58 +00:00
|
|
|
|
2021-01-21 20:37:35 +00:00
|
|
|
final newTextTheme = Theme.of(context).textTheme.apply(
|
2021-02-03 11:22:25 +00:00
|
|
|
bodyColor: Opaque.current().mainTextColor(),
|
|
|
|
displayColor: Opaque.current().mainTextColor(),
|
|
|
|
);
|
2021-01-06 23:09:58 +00:00
|
|
|
|
2021-01-27 20:18:28 +00:00
|
|
|
return MultiProvider(
|
2021-02-03 11:22:25 +00:00
|
|
|
providers: [getFlwtchStateProvider(), getProfileListProvider(), getOpaqueProvider()],
|
|
|
|
builder: (context, widget) {
|
|
|
|
return Consumer<OpaqueTheme>(
|
|
|
|
builder: (context, opaque, child) => MaterialApp(
|
2021-02-23 02:55:10 +00:00
|
|
|
locale: Locale("es",''),
|
|
|
|
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
|
|
|
supportedLocales: AppLocalizations.supportedLocales,
|
2021-02-03 11:22:25 +00:00
|
|
|
title: 'Cwtch',
|
|
|
|
theme: ThemeData(
|
|
|
|
visualDensity: VisualDensity.adaptivePlatformDensity,
|
|
|
|
primarySwatch: Colors.red,
|
|
|
|
primaryColor: opaque.current().backgroundMainColor(),
|
|
|
|
canvasColor: opaque.current().backgroundPaneColor(),
|
|
|
|
accentColor: opaque.current().defaultButtonColor(),
|
|
|
|
buttonColor: opaque.current().defaultButtonColor(),
|
|
|
|
textTheme: newTextTheme,
|
|
|
|
),
|
|
|
|
// from dan: home: cwtchInit == true ? ProfileMgrView(cwtch) : SplashView(),
|
|
|
|
// from erinn: home: columns.length == 3 ? TripleColumnView() : ProfileMgrView(),
|
|
|
|
home: cwtchInit == true ? (columns.length == 3 ? TripleColumnView() : ProfileMgrView()) : SplashView(),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2021-01-27 20:18:28 +00:00
|
|
|
);
|
2021-01-06 23:09:58 +00:00
|
|
|
}
|
2021-01-27 20:18:28 +00:00
|
|
|
}
|