Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement theming PapercupStyle(), Flutter 3.0 support and more #89

Merged
merged 9 commits into from
May 27, 2022
427 changes: 376 additions & 51 deletions README.md

Large diffs are not rendered by default.

62 changes: 24 additions & 38 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ class _MyHomePageState extends State<MyHomePage> {
var show = true;
var elevated = false;

TextEditingController titleController =
TextEditingController(text: "Welcome to Papercups!");
TextEditingController subtitleController =
TextEditingController(text: "Ask us anything using the chat window!");
TextEditingController titleController = TextEditingController(text: "Welcome to Papercups!");
TextEditingController subtitleController = TextEditingController(text: "Ask us anything using the chat window!");
Color color = Color(0xff1890ff);

@override
Expand Down Expand Up @@ -117,8 +115,7 @@ class _MyHomePageState extends State<MyHomePage> {
ElevatedButton.icon(
icon: Icon(Icons.code_rounded),
onPressed: () {
launch(
"https://github.com/papercups-io/papercups_flutter");
launch("https://github.com/papercups-io/papercups_flutter");
},
label: Text("View the code"),
),
Expand All @@ -129,19 +126,16 @@ class _MyHomePageState extends State<MyHomePage> {
color: Color(0xff1890ff),
),
onPressed: () {
launch(
"https://pub.dev/packages/papercups_flutter");
launch("https://pub.dev/packages/papercups_flutter");
},
label: Text(
"View the Package",
style: TextStyle(color: Colors.black),
),
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.resolveWith<Color>(
backgroundColor: MaterialStateProperty.resolveWith<Color>(
(Set<MaterialState> states) {
return Colors
.white; // Use the component's default.
return Colors.white; // Use the component's default.
},
),
),
Expand All @@ -151,8 +145,7 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(
height: 20,
),
Text(
"Hello! Try customizing the chat widget's display text and colors."),
Text("Hello! Try customizing the chat widget's display text and colors."),
Divider(
height: 20,
),
Expand All @@ -170,8 +163,7 @@ class _MyHomePageState extends State<MyHomePage> {
ThemeModeSelector(
height: 25,
onChanged: (mode) {
ThemeModeManager.of(context)!.themeMode =
mode;
ThemeModeManager.of(context)!.themeMode = mode;
}),
],
),
Expand Down Expand Up @@ -209,11 +201,9 @@ class _MyHomePageState extends State<MyHomePage> {
hintText: 'Enter a title',
contentPadding: EdgeInsets.all(10),
isCollapsed: true,
border: const OutlineInputBorder(
borderRadius: BorderRadius.zero),
border: const OutlineInputBorder(borderRadius: BorderRadius.zero),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Color(0xff1890ff)),
borderRadius: BorderRadius.zero),
borderSide: BorderSide(color: Color(0xff1890ff)), borderRadius: BorderRadius.zero),
),
),
),
Expand Down Expand Up @@ -245,8 +235,7 @@ class _MyHomePageState extends State<MyHomePage> {
SizedBox(
height: 40,
),
Text(
"Try changing the color (you can enter any value you want!)"),
Text("Try changing the color (you can enter any value you want!)"),
SizedBox(
height: 15,
),
Expand Down Expand Up @@ -296,23 +285,22 @@ class _MyHomePageState extends State<MyHomePage> {
margin: EdgeInsets.all(20),
child: ClipRRect(
borderRadius: BorderRadius.circular(15),
child: PaperCupsWidget(
floatingSendMessage: elevated,
closeAction: () {
setState(() {
show = !show;
});
},
props: Props(
child: PapercupsWidget(
props: PapercupsProps(
accountId: "843d8a14-8cbc-43c7-9dc9-3445d427ac4e",
translations: PapercupsIntl(
title: titleController.text,
subtitle: subtitleController.text,
greeting:
"Hello, have any questions or feedback? Let me know below!",
greeting: "Hello, have any questions or feedback? Let me know below!",
),
primaryColor: color,
customer: CustomerMetadata(
floatingSendMessage: elevated,
closeAction: () {
setState(() {
show = !show;
});
},
style: PapercupsStyle(primaryColor: color),
customer: PapercupsCustomerMetadata(
email: "admin@aguilaair.tech",
externalId: "123",
),
Expand All @@ -334,12 +322,10 @@ class ThemeModeManager extends StatefulWidget {
final Widget Function(ThemeMode? themeMode)? builder;
final ThemeMode? defaultThemeMode;

const ThemeModeManager({Key? key, this.builder, this.defaultThemeMode})
: super(key: key);
const ThemeModeManager({Key? key, this.builder, this.defaultThemeMode}) : super(key: key);

@override
_ThemeModeManagerState createState() =>
_ThemeModeManagerState(themeMode: defaultThemeMode);
_ThemeModeManagerState createState() => _ThemeModeManagerState(themeMode: defaultThemeMode);

static _ThemeModeManagerState? of(BuildContext context) {
return context.findAncestorStateOfType<_ThemeModeManagerState>();
Expand Down
15 changes: 11 additions & 4 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ packages:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.0.3"
fake_async:
dependency: transitive
description:
Expand Down Expand Up @@ -184,6 +184,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta:
dependency: transitive
description:
Expand All @@ -204,7 +211,7 @@ packages:
path: ".."
relative: true
source: path
version: "3.0.0-beta.1"
version: "3.0.0"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -260,7 +267,7 @@ packages:
name: phoenix_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.0"
version: "0.5.3"
platform:
dependency: transitive
description:
Expand Down Expand Up @@ -342,7 +349,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.3"
version: "0.4.8"
thememode_selector:
dependency: "direct main"
description:
Expand Down