You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: best-practices/index.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,12 @@ title: Best Practices
4
4
5
5
## NativeScript Best Practices
6
6
7
+
### The story of 😢 or 😊
8
+
7
9
Over the years several distinct best practices have emerged when working with NativeScript and we'd like to outline a few here for you in hopes that you can enjoy NativeScripting as much as we do. More importantly though, that your end product gives you all the right _feels_ you expect.
8
10
9
-
We are providing a sample "vanilla" NativeScript app which shows some of the good vs. bad practices for you to run and see for yourself.
10
-
Using vanilla NativeScript is a great way to see the raw examples of why these are good and bad practices and are applicable to any frontend framework integration. Each framework integration effectively utilitizes these same practices for it's own various cases.
11
+
We are providing a sample "vanilla" NativeScript app which shows some of the bad vs. good practices for you to run and see for yourself.
12
+
Using vanilla NativeScript is a great way to see the raw examples of why these are bad and good practices which are applicable to any frontend framework integration. Each framework integration effectively utilitizes these same practices for it's own various cases.
11
13
12
14
Clone and see for yourself: https://github.com/NativeScript/examples-best-practices
Copy file name to clipboardExpand all lines: code-sharing/index.md
+49-29Lines changed: 49 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,12 @@
2
2
title: Code Sharing
3
3
---
4
4
5
+
JavaScript provides opportunities of immense scalability if architectured properly.
6
+
7
+
One key word that often comes up in this department is **"code sharing"**.
8
+
9
+
Over the years, several lessons have emerged around scalability with JavaScript in lieu of NativeScript in particular.
10
+
5
11
**The NativeScript TSC's 5 fundamental lessons about good code sharing**
6
12
7
13
1. If you can share your code easily with other paradigms, other disciplines, other runtimes even, then you have a good code sharing approach that will continue to provide you and your team joy. No developer or team willingly gets into code sharing hoping to find themselves in a corner later. You always want to share now to more easily maintain and scale the code later.
@@ -22,46 +28,60 @@ If a "code sharing solution" is maintained by a framework that can often mean th
22
28
23
29
## Recommendations and Solutions
24
30
25
-
-[Nx with xplat](https://nstudio.io/xplat)
31
+
### [Nrwl Nx DevTools with @nativescript/nx](https://github.com/NativeScript/nx)
32
+
33
+
**Pros:**
34
+
35
+
- It's centered around JavaScript/TypeScript (lesson 1 and 5 above)
36
+
- Uses standard build tooling like typescript or webpack to build code (lesson 2 above)
37
+
- No custom file extensions to deal with (lesson 3 above)
38
+
- Nx splits up "apps" and "libs" clearly identifying deployment/distribution targets "apps" that consume shared code "libs" (lesson 4 above)
39
+
40
+
**Cons:**
41
+
42
+
- Learning curve if not used to Nx practices in general
43
+
44
+
### [Nrwl Nx DevTools with @nstudio/xplat](https://nstudio.io/xplat)
26
45
27
-
**Pros:**
46
+
**Pros:**
28
47
29
-
- It's centered around JavaScript/TypeScript (lesson 1 and 5 above)
30
-
- Uses standard build tooling like typescript or webpack to build code (lesson 2 above)
31
-
- No custom file extensions to deal with (lesson 3 above)
32
-
- Nx splits up "apps" and "libs" clearly identifying deployment/distribution targets "apps" that consume shared code "libs" (lesson 4 above)
33
-
- Opinionated architecture is provided via xplat which helps to avoid common pitfalls from hard lessons learned in real world developments with cross platform mixtures
48
+
- It's centered around JavaScript/TypeScript (lesson 1 and 5 above)
49
+
- Uses standard build tooling like typescript or webpack to build code (lesson 2 above)
50
+
- No custom file extensions to deal with (lesson 3 above)
51
+
- Nx splits up "apps" and "libs" clearly identifying deployment/distribution targets "apps" that consume shared code "libs" (lesson 4 above)
52
+
- It builds upon @nativescript/nx to further scale it across more paradigms so it's a natural extension when needed if already working in Nx with @nativescript/nx
53
+
- Opinionated architecture is provided via xplat which helps to avoid common pitfalls from hard lessons learned in real world developments with cross platform mixtures
34
54
35
-
**Cons:**
55
+
**Cons:**
36
56
37
-
- Learning curve if not used to Nx practices in general
38
-
- Learning curve if you have not developed applications in large codebases before
39
-
- Understanding the [basic fundamentals](https://nstudio.io/xplat/fundamentals/architecture) of the provided architecture
57
+
- Learning curve if not used to Nx practices in general
58
+
- Learning curve if you have not developed applications in large codebases before
59
+
- Understanding the [basic fundamentals](https://nstudio.io/xplat/fundamentals/architecture) of the provided architecture
Copy file name to clipboardExpand all lines: ui-and-styling.md
+116Lines changed: 116 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -489,6 +489,122 @@ The following example creates a diagonal stack of items with responsive sizes. I
489
489
490
490
None.
491
491
492
+
### RootLayout
493
+
494
+
`<RootLayout>` is a layout container designed to be used as the primary root layout container for your app with a built in api to easily control dynamic view layers. It extends a GridLayout so has all the features of a grid but enhanced with additional apis.
You can use `getRootLayout()` to get a reference to the root layout in your app from anywhere.
541
+
542
+
#### Example: RootLayout setup
543
+
544
+
Sample layout:
545
+
546
+
```html
547
+
<RootLayoutheight="100%"width="100%">
548
+
<GridLayoutheight="100%">
549
+
<label
550
+
verticalAlignment="center"
551
+
textAlignment="center"
552
+
text="MAIN CONTENT AREA"
553
+
></label>
554
+
</GridLayout>
555
+
</RootLayout>
556
+
```
557
+
558
+
Sample api usage:
559
+
560
+
```ts
561
+
// Open a dynamic popup
562
+
const view =this.getPopup('#EA5936', 110, -30)
563
+
getRootLayout()
564
+
.open(view, {
565
+
shadeCover: {
566
+
color: '#000',
567
+
opacity: 0.7,
568
+
tapToClose: true
569
+
},
570
+
animation: {
571
+
enterFrom: {
572
+
opacity: 0,
573
+
translateY: 500,
574
+
duration: 500
575
+
},
576
+
exitTo: {
577
+
opacity: 0,
578
+
duration: 300
579
+
}
580
+
}
581
+
})
582
+
.catch(ex=>console.error(ex))
583
+
584
+
// Close the dynamic popup
585
+
getRootLayout()
586
+
.close(view, {
587
+
opacity: 0,
588
+
translate: { x: 0, y: -500 }
589
+
})
590
+
.catch(ex=>console.error(ex))
591
+
592
+
function getPopup(color:string, size:number, offset:number):View {
593
+
const layout =newStackLayout()
594
+
layout.height=size
595
+
layout.width=size
596
+
layout.marginTop=offset
597
+
layout.marginLeft=offset
598
+
layout.backgroundColor=color
599
+
layout.borderRadius=10
600
+
returnlayout
601
+
}
602
+
```
603
+
604
+
You can play with [the toolbox app here](https://github.com/NativeScript/NativeScript/tree/master/apps/toolbox/src/pages/root-layout.ts)
605
+
606
+
You can also find a more [thorough example in this sample repo](https://github.com/williamjuan027/nativescript-rootlayout-demo)
607
+
492
608
### WrapLayout
493
609
494
610
`<WrapLayout>` is a layout container that lets you position items in rows or columns, based on the `orientation` property. When the space is filled, the container automatically wraps items onto a new row or column.
0 commit comments