-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #280 from e-picsa/feat-resource-share
Feat: Resource share functionality
- Loading branch information
Showing
18 changed files
with
191 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,3 +30,9 @@ | |
color: var(--color-primary); | ||
} | ||
} | ||
.share-link { | ||
position: absolute; | ||
top: -6px; | ||
right: -6px; | ||
z-index: 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...icsa-tools/resources-tool/src/app/components/resource-share/resource-share.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<button class="share-button" mat-icon-button (click)="share()"> | ||
<mat-icon>share</mat-icon> | ||
</button> |
3 changes: 3 additions & 0 deletions
3
...icsa-tools/resources-tool/src/app/components/resource-share/resource-share.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
:host { | ||
display: block; | ||
} |
22 changes: 22 additions & 0 deletions
22
...a-tools/resources-tool/src/app/components/resource-share/resource-share.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ResourceShareComponent } from './resource-share.component'; | ||
|
||
describe('ResourceShareComponent', () => { | ||
let component: ResourceShareComponent; | ||
let fixture: ComponentFixture<ResourceShareComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
declarations: [ResourceShareComponent], | ||
}).compileComponents(); | ||
|
||
fixture = TestBed.createComponent(ResourceShareComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
32 changes: 32 additions & 0 deletions
32
.../picsa-tools/resources-tool/src/app/components/resource-share/resource-share.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, input } from '@angular/core'; | ||
import { Capacitor } from '@capacitor/core'; | ||
import { RxAttachment } from 'rxdb'; | ||
|
||
import { IResourceFile } from '../../schemas'; | ||
import { ResourcesToolService } from '../../services/resources-tool.service'; | ||
|
||
@Component({ | ||
selector: 'resource-share', | ||
templateUrl: './resource-share.component.html', | ||
styleUrls: ['./resource-share.component.scss'], | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class ResourceShareComponent { | ||
public attachment?: RxAttachment<IResourceFile>; | ||
|
||
link = input.required<string>(); | ||
uri = input<string>(); | ||
|
||
constructor(private service: ResourcesToolService, private cdr: ChangeDetectorRef) {} | ||
|
||
public async share() { | ||
// on native prefer to share file directly | ||
const uri = this.uri(); | ||
if (Capacitor.isNativePlatform() && uri) { | ||
this.service.shareFileNative(uri); | ||
// fallback to sharing link on web and non-file type | ||
} else { | ||
this.service.shareLink(this.link()); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters