Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
EsinShadrach committed Apr 24, 2024
1 parent 663e973 commit 9f85693
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 64 deletions.
8 changes: 8 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import "package:flutter_playground/providers/color_provider.dart";
import "package:flutter_playground/routes.dart";
import "package:flutter_playground/screens/change_color_scheme.dart";
import "package:provider/provider.dart";
import 'package:lucide_icons/lucide_icons.dart';

void main() {
runApp(
Expand All @@ -29,6 +30,13 @@ class MyApp extends StatelessWidget {
title: "Flutter Demo",
routes: routes(),
debugShowCheckedModeBanner: false,
builder: (context, child) {
return Scaffold(
body: SafeArea(
child: child!,
),
);
},
onUnknownRoute: (settings) {
return MaterialPageRoute(
builder: (context) => const Scaffold(
Expand Down
124 changes: 61 additions & 63 deletions lib/screens/change_color_scheme.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import "package:flutter/material.dart";
import "package:flutter/services.dart";
import "package:flutter_playground/extensions.dart";
Expand All @@ -20,76 +19,75 @@ class UpdateColorSchemeScreen extends StatelessWidget {
appBar: AppBar(
title: const Text("Update ColorScheme"),
),
body: SafeArea(
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) =>
const SizedBox(height: 10),
itemCount: Colors.primaries.length + 1,
itemBuilder: (context, index) => index == 0
? Consumer<ColorProvider>(
builder: (context, value, child) =>
SwitchListTile.adaptive(
value: value.isLightMode,
title: const Text("Toggle Brightness"),
inactiveTrackColor:
context.colorScheme.primary.withOpacity(0.2),
activeTrackColor: context.colorScheme.primary,
thumbIcon: MaterialStatePropertyAll(
value.isLightMode
? const Icon(Icons.sunny)
: Icon(
Icons.dark_mode_rounded,
color: context.colorScheme.onBackground,
),
),
onChanged: (isOn) => value.toggleBrightness(isOn),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: [
Expanded(
child: ListView.separated(
separatorBuilder: (context, index) =>
const SizedBox(height: 10),
itemCount: Colors.primaries.length + 1,
itemBuilder: (context, index) => index == 0
? Consumer<ColorProvider>(
builder: (context, value, child) =>
SwitchListTile.adaptive(
value: value.isLightMode,
title: const Text("Toggle Brightness"),
inactiveTrackColor:
context.colorScheme.primary.withOpacity(0.2),
activeTrackColor: context.colorScheme.primary,
thumbIcon: MaterialStatePropertyAll(
value.isLightMode
? const Icon(Icons.sunny)
: Icon(
Icons.dark_mode_rounded,
color: context.colorScheme.onBackground,
),
),
)
: Consumer<ColorProvider>(
builder: (context, value, child) => ListTile(
onTap: () {
value.updateFn(Colors.primaries[index - 1]);
},
tileColor: Colors.primaries[index - 1],
shape: const ContinuousRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
onChanged: (isOn) => value.toggleBrightness(isOn),
),
)
: Consumer<ColorProvider>(
builder: (context, value, child) => ListTile(
onTap: () {
value.updateFn(Colors.primaries[index - 1]);
},
tileColor: Colors.primaries[index - 1],
shape: const ContinuousRectangleBorder(
borderRadius: BorderRadius.all(
Radius.circular(20),
),
title: Padding(
padding: const EdgeInsets.all(8.0),
// child: Text("Color Scheme"),
child: Text(
grabColor(
Colors.primaries[index - 1].toString()),
),
title: Padding(
padding: const EdgeInsets.all(8.0),
// child: Text("Color Scheme"),
child: Text(
grabColor(
Colors.primaries[index - 1].toString(),
),
),
trailing: IconButton(
onPressed: () async {
var colorVal = grabColor(
Colors.primaries[index - 1].toString(),
);
),
trailing: IconButton(
onPressed: () async {
var colorVal = grabColor(
Colors.primaries[index - 1].toString(),
);

ClipboardData data = ClipboardData(
text: colorVal,
);
await Clipboard.setData(data);
},
tooltip: "Copy Color",
icon: const Icon(Icons.copy_rounded),
),
contentPadding: EdgeInsets.zero,
ClipboardData data = ClipboardData(
text: colorVal,
);
await Clipboard.setData(data);
},
tooltip: "Copy Color",
icon: const Icon(Icons.copy_rounded),
),
contentPadding: EdgeInsets.zero,
),
),
),
),
],
),
),
],
),
),
);
Expand Down
10 changes: 9 additions & 1 deletion pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.1.1"
lucide_icons:
dependency: "direct main"
description:
name: lucide_icons
sha256: ad24d0fd65707e48add30bebada7d90bff2a1bba0a72d6e9b19d44246b0e83c4
url: "https://pub.dev"
source: hosted
version: "0.257.0"
matcher:
dependency: transitive
description:
Expand Down Expand Up @@ -226,4 +234,4 @@ packages:
version: "13.0.0"
sdks:
dart: ">=3.2.5 <4.0.0"
flutter: ">=1.16.0"
flutter: ">=1.17.0"
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ dependencies:

cupertino_icons: ^1.0.2
provider: ^6.1.2
lucide_icons: ^0.257.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 9f85693

Please sign in to comment.