Skip to content

Commit

Permalink
Merge pull request #11 from Agondev/master
Browse files Browse the repository at this point in the history
1. Change copy icon to copy code instead of link
  • Loading branch information
X-Wei committed Jun 26, 2021
2 parents 50de60d + c8e4a81 commit 6cbd552
Show file tree
Hide file tree
Showing 13 changed files with 414 additions and 316 deletions.
4 changes: 4 additions & 0 deletions .gitignore
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
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
@@ -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
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
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
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 6cbd552

Please sign in to comment.