Skip to content

Commit

Permalink
1. Change copy icon to copy code instead of link
Browse files Browse the repository at this point in the history
2. Added more parameters to ctor to customize the widget

3. Changed folder/file structure to comform to standard

4. Added copyWith to SyntaxHighlighterStyle

5. Modified example app by removing example.dart and moving everything into main.dart

6. Changed example app to show its own code and made it more verbose
  • Loading branch information
noga-dev committed Jun 17, 2021
1 parent 50de60d commit c8e4a81
Show file tree
Hide file tree
Showing 13 changed files with 414 additions and 316 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
.buildlog/
.history
.svn/
.vscode/

# IntelliJ related
*.iml
Expand All @@ -29,6 +30,7 @@
.pub-cache/
.pub/
build/
pubspec.lock

# Android related
**/android/**/gradle-wrapper.jar
Expand Down Expand Up @@ -71,3 +73,5 @@ build/
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
example/.gitignore
example/pubspec.lock
2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
**/android/
**/ios/
**/macos/
**/windows/
**/web/

# IntelliJ related
*.iml
Expand Down
12 changes: 0 additions & 12 deletions example/lib/example.dart

This file was deleted.

80 changes: 54 additions & 26 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,45 +1,73 @@
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:widget_with_codeview/widget_with_codeview.dart';

import 'example.dart';

void main() {
runApp(MyApp());
}

/// ensure the files in sourceFilePath are included in pubspec.yaml
/// in this case the codeViewer will display this file's code
/// by pointing to the main.dart file
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
theme: ThemeData.dark(),
home: Scaffold(
body: WidgetWithCodeView(
child: const SomeWidget(),
sourceFilePath: 'lib/main.dart',
codeLinkPrefix: 'https://google.com?q=',
iconBackgroundColor: Colors.white,
iconForegroundColor: Colors.pink,
labelBackgroundColor: Theme.of(context).canvasColor,
labelTextStyle:
TextStyle(color: Theme.of(context).textTheme.bodyText1.color),
showLabelText: true,
syntaxHighlighterStyle:
SyntaxHighlighterStyle.darkThemeStyle().copyWith(
commentStyle: TextStyle(color: Colors.yellow),
keywordStyle: TextStyle(color: Colors.lightGreen),
classStyle: TextStyle(color: Colors.amber),
numberStyle: TextStyle(color: Colors.orange),
),
),
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}
class SomeWidget extends StatelessWidget {
const SomeWidget({Key key}) : super(key: key);

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: WidgetWithCodeView(
child: Example(),
sourceFilePath: 'lib/example.dart',
),
);
}
Widget build(BuildContext context) => Stack(
children: [
Center(
child: Transform.rotate(
angle: Random().nextDouble(),
child: Text(
'Example',
textScaleFactor: 2,
),
),
),
Wrap(
children: List.generate(
100,
(_) => SizedBox(
width: MediaQuery.of(context).size.width * .25,
height: MediaQuery.of(context).size.width * .25,
child: Placeholder(
color: Colors.accents[Random().nextInt(
Colors.accents.length,
)],
),
),
),
),
],
);
}
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ packages:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -223,7 +223,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
Expand Down Expand Up @@ -258,7 +258,7 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19"
version: "0.3.0"
typed_data:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ flutter:
uses-material-design: true

assets:
- lib/example.dart
- lib/
15 changes: 7 additions & 8 deletions example/test/widget_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
// gestures. You can also use WidgetTester to find child widgets in the widget
// tree, read text, and verify that the values of widget properties are correct.

import 'package:example/main.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
// import 'package:example/main.dart';
// import 'package:flutter_test/flutter_test.dart';

void main() {
testWidgets('smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
await tester.pumpWidget(MyApp());
// testWidgets('smoke test', (WidgetTester tester) async {
// // Build our app and trigger a frame.
// // await tester.pumpWidget(MyApp());

expect(find.text('1'), findsNothing);
});
// // expect(find.text('1'), findsNothing);
// });
}
133 changes: 0 additions & 133 deletions lib/source_code_view.dart

This file was deleted.

0 comments on commit c8e4a81

Please sign in to comment.