2021-03-16 19:54:48 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
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-03-09 01:23:37 +00:00
|
|
|
import 'package:flutter_app/settings.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-03-16 19:54:48 +00:00
|
|
|
import 'licenses.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_gen/gen_l10n/app_localizations.dart';
|
2021-02-25 23:33:15 +00:00
|
|
|
|
2021-03-16 21:04:14 +00:00
|
|
|
var globalSettings = Settings(Locale("en", ''), Opaque.dark);
|
2021-03-10 17:40:14 +00:00
|
|
|
|
2021-03-16 19:54:48 +00:00
|
|
|
void main() {
|
|
|
|
LicenseRegistry.addLicense(() => licenses());
|
|
|
|
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-03-09 01:23:37 +00:00
|
|
|
|
2021-02-03 11:22:25 +00:00
|
|
|
profs = ProfileListState();
|
2021-03-16 21:04:14 +00:00
|
|
|
var cwtchNotifier = new CwtchNotifier(profs, globalSettings);
|
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-03-17 22:54:41 +00:00
|
|
|
ChangeNotifierProvider<Settings> getSettingsProvider() => ChangeNotifierProvider.value(value: globalSettings);
|
2021-03-16 23:33:03 +00:00
|
|
|
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-27 20:18:28 +00:00
|
|
|
return MultiProvider(
|
2021-03-16 23:33:03 +00:00
|
|
|
providers: [getFlwtchStateProvider(), getProfileListProvider(), getSettingsProvider()],
|
2021-02-03 11:22:25 +00:00
|
|
|
builder: (context, widget) {
|
2021-03-09 01:23:37 +00:00
|
|
|
Provider.of<Settings>(context).initPackageInfo();
|
2021-03-10 17:40:14 +00:00
|
|
|
return Consumer<Settings>(
|
2021-02-03 11:22:25 +00:00
|
|
|
builder: (context, opaque, child) => MaterialApp(
|
2021-03-09 01:23:37 +00:00
|
|
|
locale: Provider.of<Settings>(context).locale,
|
2021-02-23 02:55:10 +00:00
|
|
|
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(),
|
2021-03-09 01:23:37 +00:00
|
|
|
backgroundColor: opaque.current().backgroundMainColor(),
|
2021-03-10 17:40:14 +00:00
|
|
|
iconTheme: IconThemeData(
|
2021-03-09 01:23:37 +00:00
|
|
|
color: opaque.current().mainTextColor(),
|
|
|
|
),
|
|
|
|
cardColor: opaque.current().backgroundMainColor(),
|
2021-03-10 17:40:14 +00:00
|
|
|
textButtonTheme: TextButtonThemeData(
|
2021-03-09 01:23:37 +00:00
|
|
|
style: ButtonStyle(
|
2021-03-16 23:33:03 +00:00
|
|
|
backgroundColor: MaterialStateProperty.all(opaque.current().defaultButtonColor()),
|
|
|
|
foregroundColor: MaterialStateProperty.all(opaque.current().defaultButtonTextColor()),
|
|
|
|
overlayColor: MaterialStateProperty.all(opaque.current().defaultButtonActiveColor()),
|
2021-03-10 17:40:14 +00:00
|
|
|
padding: MaterialStateProperty.all(EdgeInsets.all(20))),
|
2021-03-09 01:23:37 +00:00
|
|
|
),
|
2021-03-10 17:40:14 +00:00
|
|
|
dialogTheme: DialogTheme(
|
|
|
|
backgroundColor: opaque.current().backgroundPaneColor(),
|
2021-03-16 23:33:03 +00:00
|
|
|
titleTextStyle: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
contentTextStyle: TextStyle(color: opaque.current().mainTextColor())),
|
2021-03-09 01:23:37 +00:00
|
|
|
textTheme: TextTheme(
|
2021-03-10 17:40:14 +00:00
|
|
|
headline1: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
headline2: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
headline3: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
headline4: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
headline5: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
headline6: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
bodyText1: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
bodyText2: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
subtitle1: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
subtitle2: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
caption: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
button: TextStyle(color: opaque.current().mainTextColor()),
|
|
|
|
overline: TextStyle(color: opaque.current().mainTextColor())),
|
2021-02-03 11:22:25 +00:00
|
|
|
),
|
|
|
|
// from dan: home: cwtchInit == true ? ProfileMgrView(cwtch) : SplashView(),
|
|
|
|
// from erinn: home: columns.length == 3 ? TripleColumnView() : ProfileMgrView(),
|
2021-03-16 23:33:03 +00:00
|
|
|
home: cwtchInit == true ? (columns.length == 3 ? TripleColumnView() : ProfileMgrView()) : SplashView(),
|
2021-02-03 11:22:25 +00:00
|
|
|
),
|
|
|
|
);
|
|
|
|
},
|
2021-01-27 20:18:28 +00:00
|
|
|
);
|
2021-01-06 23:09:58 +00:00
|
|
|
}
|
2021-01-27 20:18:28 +00:00
|
|
|
}
|